Suppose I have a few urls like: http://www.digitalpoint.com/world-is-big.html http://www.digitalpoint.com/round-world.html http://www.digitalpoint.com/hello-world.html etc in which a common string "world" is there. Now I want that whenever a user go for an url which has the string world in it will ge redirect to another page like http://www.digitalpoint.com/index.php?id=world. How to write the redirect rule for this?
I tried for whole night and finally got it. it will be RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^digitalpoint.com$ RewriteRule ^(.+)(world)(.+)\.html$ "http\:\/\/www\.digitalpoint\.com\/index\.php\?id\=world" [R=301,L] RewriteRule ^(world)(.+)\.html$ "http\:\/\/www\.digitalpoint\.com\/index\.php\?id\=world" [R=301,L] RewriteRule ^(.+)(world)\.html$ "http\:\/\/www\.digitalpoint\.com\/index\.php\?id\=world" [R=301,L] I have written three rules for abouve three urls but I think there is way of writing them all in one rule using the ? wildcard. I haven't tried it coz all of my urls have that particular keyword somewhere in the middle so i just needed the first rule. But i think it will be.... RewriteRule ^((.+)?)(world)((.+)?)\.html$ "http\:\/\/www\.digitalpoint\.com\/index\.php\?id\=world" [R=301,L]