Mobile app version of vmapp.org
Login or Join
Marchetta884

: How to redirect all mobile folder files to main folder file using htacess our previous website have one sub directory called "mobile". So in the main pages we write code if it is screen size

@Marchetta884

Posted in: #Apache #Htaccess #Html #ModRewrite

our previous website have one sub directory called "mobile". So in the main pages we write code if it is screen size less than 640px then got to mobile/ folder .

<link href="http://mobile.example.com/index.html/" media="only screen and (max-width: 640px)" rel="alternate" />


For example , someone take example.com/index.html website from mobile, they are redirected to mobile.example.com/index.html.

Now we developed new website that is responsive & in that files we remove the redirection code. But some people bookmark our previous mobile page url .

so we want to redirect all mobile.example.com/file to example.com/file .

How we can do this ?

m.example.com => example.com
m.example.com/index.html => example.com/index.html
m.example.com/about.html => example.com/about.html

m.example.com/anything => example.com/anything

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Marchetta884

1 Comments

Sorted by latest first Latest Oldest Best

 

@Michele947

Try this

RewriteEngine On

RewriteCond %{HTTP_HOST} m.example.com [NC]

RewriteRule ^(.*)$ www.example.com/ [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme