Keezy
Keezy

Reputation: 303

htaccess permanent redirect and remove string from url

How can I go about getting visitors who enter the site via a mobile url get redirected to the non mobile url on this example;

user visits http://website.com/*mobile/*the-page.html
redirect them to http://website.com/the-page.html

Doing a google search, I was able to come up with the follow htaccess line:

RewriteRule ^/?mobile/(.*)$ /$1 [L,R=301]

though it correctly redirects to the right page, it uses the filename of the dynamic page to do so, example:

http://website.com/index.php?id=the-page

how can I get it to just take out mobile/ from the url?

Upvotes: 0

Views: 1456

Answers (1)

Keezy
Keezy

Reputation: 303

okay, slow moment... I needed to deleted the original rewrite rules for the mobile site.

after that, it was simple as adding

RewriteRule ^mobile/(.*)$ /$1 [L,R=301]

to htaccess.

Upvotes: 1

Related Questions