EJK
EJK

Reputation: 326

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]

Upvotes: 0

Views: 64

Answers (1)

Croises
Croises

Reputation: 18671

You can use:

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

Upvotes: 1

Related Questions