我试图用Apache的mod_rewrite创build一个干净的URL的PHP网站,使用.htaccess文件。 mod_rewrite似乎工作,但是,它声称它不能find我的服务器上存在的文件。
就像一个基本的testing,这是我的.htaccess文件现在看起来像 – 去[mysite] /页面应该redirect到index.php文件:
Options +FollowSymLinks RewriteEngine on RewriteRule ^page$ index.php
Afaik,我也正确设置了.conf文件:
<Directory "/Users/myuser/Sites/"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
但是,当我尝试通过mod_rewrite(localhost /〜myuser / mysite / page)访问URL设置时,我得到这个:
Not Found The requested URL /Users/myuser/Sites/mysite/index.php was not found on this server.
但是,该文件确实存在,这是正确的位置! 如果我去localhost /〜myuser / mysite / index.php,一切正常 – 当然减去任何干净的URL,该网站工作正常。
有没有人看过这个/有任何想法,我做错了什么?
你需要RewriteBase,如果你在你的userdir中,并replace为相对path。
Multiviews后必须添加FollowSymlinks。 我在这里写了一个教程:
http://www.jermexpress.com/how-to-enable-mod_rewrite-on-snow-leopard-10-6/
希望能解决你的问题。 干杯! 🙂