In .htaccess remove word from URL

2019-01-18 07:39发布

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]

2条回答
三岁会撩人
2楼-- · 2019-01-18 08:18

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

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

查看更多
放荡不羁爱自由
3楼-- · 2019-01-18 08:30

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]
查看更多
登录 后发表回答