2014-04-13 59 views

回答

0

這應該爲你工作:

RewriteEngine On 
#External redirect with THE_REQUEST trick; change R to R=301 when everything works correctly 
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index\.php\?page=(.*)\ HTTP 
RewriteRule^/%2.php\? [R=302,L] 

#Internal rewrite 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*).php$ /index.php?page=$1 [L] 

如果您訪問http://example.com/index.php?page=about將您重定向到http://example.com/about.php

+0

謝謝,工作!但是現在ErrorDocument 404不再工作了。當我訪問一個以.php結尾的不存在的頁面時,我會看到一個白色的網站。當不存在的頁面不以.php結尾時,一切正常。 – iCON

+0

是否有很多頁面需要使用上述代碼重定向? – Howli

+0

是的,有。 – iCON