简体   繁体   中英

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]

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

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM