2014-10-19 20 views
2

我有這2個重寫規則。但是有沒有一種方法可以合併爲1規則,無論URL是.php還是.html,重定向都會發生?一個用於HTML和PHP重定向的RewriteRule

RewriteCond %{HTTP_HOST} ^(www\.)?url\.com$ 
RewriteRule ^about\.html\/?(.*)$ "http\:\/\/www\.url\.com\/about\/$1" [R=301,L] 

RewriteCond %{HTTP_HOST} ^(www\.)?url\.com$ 
RewriteRule ^about\.php\/?(.*)$ "http\:\/\/www\.url\.com\/about\/$1" [R=301,L] 

回答

0

您可以使用正則表達式交替結合他們:

RewriteCond %{HTTP_HOST} ^(www\.)?url\.com$ 
RewriteRule ^about\.(html|php)/?(.*)$ http://www.url.com/about/$2 [R=301,L,NC] 
+0

並沒有爲我工作。有一個內部服務器錯誤頁面。 – optimus203 2014-10-19 12:58:25

+0

現在嘗試編輯rue並檢查Apache error.log,如果仍然得到500 – anubhava 2014-10-19 13:00:24

+0

另外,如果您有其他規則,請在您的問題中發佈這些規則。 – anubhava 2014-10-19 13:01:40