Apache 我怎样才能删除“;http://quot&引用;https://quot;及;www;从使用mod rewrite的URL?
我想从URL中删除“http://”和“https://”。我还想从中删除“www”部分。全部使用mod rewrite/.htaccess。我在这里找到的大多数相关答案都使用PHP或JavaScriptApache 我怎样才能删除“;http://quot&引用;https://quot;及;www;从使用mod rewrite的URL?,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我想从URL中删除“http://”和“https://”。我还想从中删除“www”部分。全部使用mod rewrite/.htaccess。我在这里找到的大多数相关答案都使用PHP或JavaScript e.g, "http://www.example.com" should become "example.com" "https://example.com" should become "example.com" "www.example.com" should become "examp
e.g,
"http://www.example.com" should become "example.com"
"https://example.com" should become "example.com"
"www.example.com" should become "example.com"
http://
和https://
是协议说明符。浏览器可以为用户隐藏它们,但不能通过modrewrite从URL中删除它们
要使apache modrewrite剥离www.
,请使用
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]