.htaccess 只重定向一页
我的网站就像example.com/fr/{slug} 我已在我的htaccess中使用slug重定向永久性来管理页面 但我的主页是example.com/fr/,我想将其重定向到example.com,但只限于此主页 我试过这个:.htaccess 只重定向一页,.htaccess,redirect,.htaccess,Redirect,我的网站就像example.com/fr/{slug} 我已在我的htaccess中使用slug重定向永久性来管理页面 但我的主页是example.com/fr/,我想将其重定向到example.com,但只限于此主页 我试过这个: RedirectMatch 301 "com\Wfr\W$" "com" RedirectMatch 301 "\Wfr\W$" "/" 但它不起作用 我试过这个: RedirectMatch 301 "com\Wfr\W$" "com" Redi
RedirectMatch 301 "com\Wfr\W$" "com"
RedirectMatch 301 "\Wfr\W$" "/"
但它不起作用
我试过这个:
RedirectMatch 301 "com\Wfr\W$" "com"
RedirectMatch 301 "\Wfr\W$" "/"
它可以工作,但它是一个多语言网站,例如,当我在西班牙语方面时,url就像这个example2.es/es/和指向法语版本的链接就像这个exmaple2.es/fr/,由于这个重定向规则,我仍然停留在西班牙语版本
有没有什么好主意可以让好的重定向和更改url的verison也能正常工作?我终于找到了解决方案:
RewriteCond %{HTTP_HOST} occasion.com$
RewriteCond %{REQUEST_URI} fr/$
RewriteRule ^(.*)$ / [R=301,L]
RewriteCond %{HTTP_HOST} barrel.com$
RewriteCond %{REQUEST_URI} en/$
RewriteRule ^(.*)$ / [R=301,L]
RewriteCond %{HTTP_HOST} es$
RewriteCond %{REQUEST_URI} es/$
RewriteRule ^(.*)$ / [R=301,L]
RewriteCond %{HTTP_HOST} it$
RewriteCond %{REQUEST_URI} it/$
RewriteRule ^(.*)$ / [R=301,L]
RewriteRule ^(.*)$ $1
希望这有帮助