Mobile app version of vmapp.org
Login or Join
Sue5673885

: Replace all url start with " m." to without ".m" ( m.example.com/index.html To example.com/index.html) Our previous website has one sub directory called "mobile". So in the main pages we write

@Sue5673885

Posted in: #Htaccess #Redirects #Seo

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

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


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

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

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

How can we do this?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sue5673885

1 Comments

Sorted by latest first Latest Oldest Best

 

@Harper822

Based very specifically on the information that you provided in your question, all you need to do is create a file called .htaccess in the doc root (web / httpdocs / www folder) of mobile.example.com (inside your "mobile" directory) and put in the code below. Be sure to add the most relevant version that best fits your circumstances, as indicated below:

1. Preferred version of your domain's URL is "non-www"

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^index.html(.*)$ example.com/index.html [R=301,NC]


2. Preferred version of your domain's URL is the "www" version

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^index.html(.*)$ www.example.com/index.html [R=301,NC]


As for redirecting individual pages to other individual pages, as long as the URLs are identical, and the only difference is the mobile subdomain, then you should be good to go. I have not tested this, please provide feedback!

On the other hand, if URIs for each individual directory (i.e. /directory/) or page (i.e. /page.html) on your old mobile version are different than the non-mobile version, all that you would need to..

Page to Page Redirect from subdomain:

Redirect 301 "/old-page.html" "http://www.example.com/new-page.html"


Remember, this is all taking place on the .htaccess file you created within the mobile folder.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme