我有一個網站只由來自.html
前端和我希望有漂亮的URL的.html。我的目標是這樣的漂亮的URL與參數
http://test.com/mypage.html => http://test.com/mypage
http://test.com/mypage1.html => http://test.com/mypage1
創造的東西,對於一個特定的頁面
http://test.com/my-prettlink.html?id=1 => http://test.com/my-prettlink/1
我想這.htaccess
它位於項目的根,但只有消除.html
作品。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule^%{REQUEST_URI}.html [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^my-prettylink/(\d+)*$ ./my-prettylink.html?id=$1
最後重寫路線將永遠不會達到添加
<base href='/subdirectory/' />
。它必須先來,因爲它更專業化。更一般的規則更接近尾聲。 – arkascha