简体   繁体   English

在.htaccess中,从网址中删除单词

[英]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 . 经过一个多小时的搜索,我仍然不知道如何将链接从http://site/fr/other重定向到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] . 只需删除第一个正斜杠: RewriteRule ^fr/(.*)$ /$1 [L,R=301,QSA]

Try this out at http://htaccess.madewithlove.be/ . http://htaccess.madewithlove.be/上尝试一下。

To remove '-xyz-' from the url 从网址中删除“ -xyz-”

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 ' 要从网址' http://yoursite.com/xyz/some-url.html '中删除'xyz'

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

To remove 'xyz' from the url ' http://yoursite.com/some-dir/xyz/some-url.html ' 要从网址' http://yoursite.com/some-dir/xyz/some-url.html '中删除'xyz'

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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