【发布时间】:2017-01-29 12:45:18
【问题描述】:
我最近安装了灯组并启用了 mod_rewrite:
$ sudo a2enmod rewrite
$ service apache2 restart
我可以在我的 phpinfo 上看到它:
但是当我尝试在我的 WordPress 中访问下面这样的 URL 时:
http://my-localhost/my-wordpress/whats-on/
我收到此错误:
找不到
在此找不到请求的 URL /my-wordpress/whats-on/ 服务器。
Apache/2.4.18 (Ubuntu) 服务器位于 127.0.0.1 端口 80
我还能做什么?我错过了什么吗?
有什么想法吗?
我也有我的 .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my-wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my-wordpress/index.php [L]
</IfModule>
# END WordPress
但是为什么呢?
编辑:
我创建了一个简单的测试:
RewriteRule ^test.html$ test.php [L]
但我得到 404 错误,而不是被定向到 test.php
Not Found
The requested URL /mod_rewrite/basic/test.html was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 127.0.1.1 Port 80
我该如何解决这个问题?
【问题讨论】:
-
也许.htaccess 文件被忽略了?首先添加一个简单的重写规则,例如:RewriteRule ^test.html$ test.php [L] 并确保创建了一个 test.php 文件。
-
@OfirBaruch 是的,我认为你是对的。刚刚用你的建议进行了测试,我得到 404 错误而不是被定向到 test.php 那么我该如何解决这个问题?
-
您是否在主配置中设置了
AllowOverride all? -
@cen aww 我没有!现在工作。谢谢。
-
您检查过文件权限吗?并且图像中的 http_host 是 127.0.1.1 而不是 127.0.0.1。是故意的吗?