模式重写已开启(使用 info.php 测试进行检查 AllowOveride 全部位于etc/httpd/conf/httpd.conf 文件
在/var/www/html 中插入 .htaccess
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
(想要从主页重定向到wordpress子目录...)
重新启动 Apache
service httpd restart
但 Apache 主页显示...于 http://mywpblog.net
当请求为 http://mywpblog.net/wordpress 时,wordpress 主页
我错过了什么吗? (EC2/httpd 上的虚拟)谢谢
最佳答案
.htaccess 错误! 应该是(在/var/www/html 目录中)
<IfModule mod_rewrite.c>
# Turn on rewrites.
RewriteEngine on
# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Only apply to URLs that aren't already under /wp.
RewriteCond %{REQUEST_URI} !^/wordpress/
# Rewrite all those to insert /wordpress
RewriteRule ^(.*)$ /wordpress/$1
# Redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?yodojodo.net$
RewriteRule ^(/)?$ wordpress/ [L]
</IfModule>
关于.htaccess 在 Apache EC2 Linux 服务器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28072950/