我遇到了apaches mod_rewrite問題。我想用我的PHP應用程序製作乾淨的網址,但它似乎沒有給出我期待的結果。Apaches mod_rewrite問題
我使用這個代碼在我的.htaccess文件:
RewriteEngine on
RewriteRule ^project/([0-9]{4})/([0-9]{2})$ /project/index.php?q=$1&r=$2 [L]
RewriteRule ^project/([0-9]{4})$ /project/index.php?q=$1 [L]
爲了使它所以當我查看,http://localhost/user/project/system
,這將是觀看http://localhost/user/project/index.php?q=system
而不是得到任何結果的equivelant我只是得到一個典型的404錯誤。
我也只是檢查,看看是否mod_rewrite的工作原理是用取代我的.htaccess代碼:
Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*) http://www.stackoverflow.com
它正確這裏重定向我,所以mod_rewrite的肯定是工作。
根路徑到我的項目是/home/user/public_html/project
的用於查看我的項目的URL爲http://localhost/user/project
如果不再需要的信息讓我知道。
感謝
如果刪除目標路徑中的前導'/',會發生什麼情況? –
.htaccess文件位於何處?如果已經在項目/文件夾中,那麼在RewriteRule中提及它將不起作用。 – mario
@Emil - 從我所看到的,什麼都沒有。 – Syx