简体   繁体   中英

htaccess Rewrite is Not Changing Browser Address Bar

I feel like I'm missing something here. We originally used a subdomain (m.example.com) for mobile traffic. We now wish to stop using that, and we'd like all users who visit an m.example.com page to be redirected simply to example.com. Everything seems to work fine, however the address bar in the browser never changes. If users type in m.example.com, that same domain remains in the address bar. What am I missing? Here are the rewrites in my htaccess:

RewriteEngine on
  RewriteRule ^ - [E=protossl]
  RewriteCond %{HTTPS} on
  RewriteRule ^ - [E=protossl:s]

  #custom redirects
  #RewriteCond %{HTTP_HOST} ^example.com
  #RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]

You can use:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^m\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=permanent,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM