Prajila V P
Prajila V P

Reputation: 5327

htaccess rewrite rule to include a string if it is not there

How can i update my url from htaccess file to include a string if it is not there. Before my site was developed in drupal 6 and we migrated to drupal 7. My mobile urls' got changed. For example:

http://m.example.com/en/terms-of-use to http://m.example.com/en/m-terms-of-use
http://m.example.com/en/contact-us to http://m.example.com/en/m-contact-us

Google is already indexed with my previous url's and getting 404 errors. So i planned for an auto redirection from htaccess.
How can i do this without inter-fairing the main site ie. http://example.com

Upvotes: 1

Views: 188

Answers (1)

anubhava
anubhava

Reputation: 785406

You can use this rule:

RewriteCond %{HTTP_HOST} ^m\.example\.com$ [NC]
RewriteRule ^(en)/((?!m-).+)$ /$1/m-$2 [L,R=301,NC]

Upvotes: 2

Related Questions