0
我很新手在修改與.htaccess和我需要一些幫助,使其工作。使用.htaccess自動URL重寫
例如,我有這兩個網址:
- www.example.com/categories/example1
- www.example.com/categories/example2
,我想自動把它改寫爲:
- www.example.com/mypage/?cat=example1
- www.example.com/mypage/?cat=example2
有沒有辦法用.htaccess重寫?
我已經嘗試過這一點,但仍然沒有工作...
RewriteEngine On
RewriteBase/
RewriteRule ^example1([^/]*)$ mypage/?cat=$1 [L]
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD|TRACE)\ /mypage/
RewriteCond %{QUERY_STRING} name=([^\&]*)
RewriteRule ^mypage/$ categories/%1.php? [R,L]
它不工作。這是因爲我使用wordpress,我必須在代碼中添加其他內容? –
@JohnSmith如果你使用wordpress,那麼使用WordPress的內置重寫永久鏈接 –
但我不能使用.htaccess做到這一點? –