2013-03-10 96 views
-1

我想從URL中刪除「http://」和「https://」。我也想刪除「www」。也是它的一部分。全部使用mod重寫/ .htaccess。我在這裏找到的大多數相關答案都是使用PHP或JavaScript。如何刪除「http://」,「https://」和「www。」從一個URL使用國防部重寫?

e.g, 
"http://www.example.com" should become "example.com" 
"https://example.com" should become "example.com" 
"www.example.com" should become "example.com" 

回答

1

http://https://是協議說明符。瀏覽器可以爲用戶隱藏它們,但它們不能通過modrewrite從URL中刪除。

爲Apache modrewrite剝去www.,使用

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
相關問題