user804736
user804736

Reputation: 232

In .htaccess remove word from URL

After more than one hour of searching, I still can't figure out how to redirect a link from http://site/fr/other to http://site/other.

I am using this code:

RewriteEngine On
RewriteRule ^/fr/(.*)$ /$1 [L,R=301,QSA]

Upvotes: 3

Views: 11941

Answers (2)

Fry
Fry

Reputation: 325

To remove '-xyz-' from the url

RewriteRule ^(.*)-xyz-(.*).html$ http://%{SERVER_NAME}/$1-$2.html [NC,R=301,L]

To remove 'xyz' from the url 'http://yoursite.com/xyz/some-url.html'

RewriteRule ^xyz/(.*)\.html$ $1-watches.html [L,R=301]

To remove 'xyz' from the url 'http://yoursite.com/some-dir/xyz/some-url.html'

RewriteRule ^(.*)/xyz/(.*).html$ http://%{SERVER_NAME}/$1/$2.html [NC,R=301,L]

Upvotes: 2

creemama
creemama

Reputation: 6665

Just remove the first forward slash: RewriteRule ^fr/(.*)$ /$1 [L,R=301,QSA].

Try this out at http://htaccess.madewithlove.be/.

Upvotes: 8

Related Questions