我在我的 Mac OS X (Snow Leopard) 上使用内置的 Apache 对我的网站进行本地测试。目前我正在尝试为我的 PHP 网站创建干净的 URL,但我似乎无法让它工作。
这是我的.htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^gallery/page/([A-Z0-9._%+-]+) gallery/index.php?page=$1 [NC]
我想要它,这样http://localhost/gallery/page/TITLE会自动将我带到http://localhost/gallery/index.php?page=TITLE
我的http://localhost/指向本地文件夹/Users/voltm/Sites/localhost/我正在处理的网站位于http://localhost/gallery/ - 本地文件夹/Users/voltm/Sites/本地主机/画廊/
例如,当我在浏览器中输入http://localhost/gallery/page/music时,我收到 404 错误The requested URL /gallery/page/music is not found on this server。
我查看了错误日志文件,它说:
[Thu Apr 05 23:55:39 2012] [error] [client 127.0.0.1] File does not exist: /Users/voltm/Sites/localhost/gallery/page
我检查了 phpinfo() 和 httpd.conf 以查看 mod_rewrite 已加载。我已经进入 httpd.conf 和用户文件夹中的 conf 文件进行设置:
Options Indexes MultiViews FollowSymLinks
AllowOverride All AuthConfig
Order allow,deny
Allow from all
而且我也多次重启了 Apache。
我错过了什么?
编辑:固定!我不得不删除放在子文件夹中的 .htaccess 文件。