高级htaccess的 - 301域名重定向 [英] Advanced htaccess - 301 domain redirection

查看:95
本文介绍了高级htaccess的 - 301域名重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重定向我的旧域到新的。我有第二版我的网站 - 波兰语和英语。我有域名为:live-dent.pl,live-dent.com,live-dent.com.pl和livedent.pl。 我想重定向:

I want to redirect my old domain to the new one. I've two version of my site - polish and english. Domains that I have are: live-dent.pl, live-dent.com, live-dent.com.pl and livedent.pl. I want to redirect:

  • (WWW)live-dent.pl/index.php,(WWW)live-dent.com/index.php,(WWW)live-dent.com.pl/index.php和livedent.pl的index.php到 www.livedent.pl(无破折号),
  • (WWW)live-dent.pl/index_en.php,(WWW)live-dent.com/index_en.php,(WWW)live-dent.com.pl/index_en.php和livedent.pl /index_en.php到 www.live-dent.com(与破折号)。
  • (www.)live-dent.pl/index.php, (www.)live-dent.com/index.php, (www.)live-dent.com.pl/index.php and livedent.pl/index.php to www.livedent.pl (without dash),
  • (www.)live-dent.pl/index_en.php, (www.)live-dent.com/index_en.php, (www.)live-dent.com.pl/index_en.php and livedent.pl/index_en.php to www.live-dent.com (with dash).

要这个,我要重定向404错误到自定义页。此文件路径的波兰语版本是:

To this I want to redirect 404 error to a custom page. Path to polish version of this file is:

  • www.livedent.pl/404.php和
  • www.live-dent.com/404_en.php英文版本(该文件不存在,现在)。

在code,我现在已经(感谢@anubhava)是:

The code that I've now (thanks to @anubhava) is:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index_en\.php [NC]
RewriteRule ^ http://www.live-dent.com/ [R=301,L,NC]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php [NC]
RewriteRule ^ / [R=301,L,NC]

RewriteCond %{HTTP_HOST} live-dent\.pl$ [NC]
RewriteRule ^ http://www.livedent.pl%{REQUEST_URI} [R=301,L]

该规则的ErrorDocument 404 /404.php不起作用。

The rule ErrorDocument 404 /404.php doesn't work.

推荐答案

假设所有这些域共享相同的文档根目录:

Assuming all these domains share the same document root:

RewriteCond %{HTTP_HOST} ^(www\.)?live-dent\.(pl|com|com\.pl)$ [OR,NC]
RewriteCond %{HTTP_HIST} ^livedent\.pl$ [NC]
RewriteCond %{THE_REQUEST} \ /+index\.php
RewriteRule ^ http://www.livedent.pl/ [L,R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?live-dent\.(pl|com|com\.pl)$ [OR,NC]
RewriteCond %{HTTP_HIST} ^livedent\.pl$ [NC]
RewriteCond %{THE_REQUEST} \ /+index_en\.php
RewriteRule ^ http://www.live-dent.com/ [L,R=301]

这篇关于高级htaccess的 - 301域名重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆