RewriteEngine 文件夹重定向

发布于 2024-12-23 04:14:26 字数 586 浏览 0 评论 0原文

我正在编写一个重写规则,将所有网址从 mysite.co.uk/en/ 重定向到 mysite.co.uk/。我写了以下内容。只是希望有人确认它对我来说是正确的,并建议可能的改进(如果有)。

Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.co\.uk$
RewriteRule ^en/(.*)$ http://www\.mysite\.co\.uk/$1 [NC,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com\.au$
RewriteRule ^en/(.*)$ http://www\.mysite\.com\.au/$1 [NC,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.co\.nz$
RewriteRule ^en/(.*)$ http://www\.mysite\.com\.nz/$1 [NC,R=301]
RewriteEngine off

I am writing a rewrite rule to redirect all urls from mysite.co.uk/en/ to mysite.co.uk/. I have the following I have written. Just would like someone to confirm it is correct for me and suggest possible improvements if any.

Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.co\.uk$
RewriteRule ^en/(.*)$ http://www\.mysite\.co\.uk/$1 [NC,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com\.au$
RewriteRule ^en/(.*)$ http://www\.mysite\.com\.au/$1 [NC,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.co\.nz$
RewriteRule ^en/(.*)$ http://www\.mysite\.com\.nz/$1 [NC,R=301]
RewriteEngine off

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柳絮泡泡 2024-12-30 04:14:26

经过大量研究,我应该能够做到这一点:

redirect 301 /en/ http://www.mywebsite.co.uk/

redirect 301 /en/ http:// www.mywebsite.com.au/

redirect 301 /en/ http://www.mywebsite.co.nz/

我们将重定向任何要访问的网址www.mywebsite.co.uk/en/mywebsite.co.uk/en/www.mywebsite.co.uk/

After much research turns out I should be able to do just this:

redirect 301 /en/ http://www.mywebsite.co.uk/

redirect 301 /en/ http://www.mywebsite.com.au/

redirect 301 /en/ http://www.mywebsite.co.nz/

This we redirect any urls that are going to www.mywebsite.co.uk/en/ or mywebsite.co.uk/en/ to www.mywebsite.co.uk/

心不设防 2024-12-30 04:14:26

使用下面的代码

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Please REPLACE domain.com and www.newdomain.com with your actual domain name.

Use below code

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Please REPLACE domain.com and www.newdomain.com with your actual domain name.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文