我試着去了解一些基本的重寫的東西,所以我發現那位是一樣的東西:使用通配符的RewriteCond結合的標誌嗎?
RewriteCond %{HTTP_HOST} ^example.(.+)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
和:
RewriteCond %{HTTP_HOST} ^(www2.example.de|example.de)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
但如果我結合它像
RewriteCond %{HTTP_HOST} ^(www2.example|example).(.+)$ [NC]
我得到由於重定向過多導致內部服務器錯誤。
所以,我怎麼能結合使用或內部消除www和不同域的結尾:
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.name$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example.name$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.de$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example.de$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
我覺得應該是很簡單,但我只是不明白這一點...
「結合」他們做什麼?請解釋你想用mod_rewrite實現什麼? – 2013-02-26 11:31:17
第一COND重定向到example.anything www.example.com和第二COND重定向www2.example.de或example.de到www.example.com,現在我想是這樣(「WWW」 |「」)。例如(*)將被定向至www.example.com。 – Karim 2013-03-16 00:33:12
或者,也許更容易:在我最後的代碼塊我有5個的RewriteCond並希望做同樣在1周...的RewriteCond – Karim 2013-03-16 00:34:42