本文介绍了高级htaccess的 - 301域名重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要重定向我的旧域到新的。我有第二版我的网站 - 波兰语和英语。我有域名为:live-dent.pl,live-dent,live-dent.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, live-dent.pl and livedent.pl. I want to redirect:
- (WWW)live-dent.pl/index.php,(WWW)live-dent/index.php,(WWW)live-dent.pl/index.php和livedent.pl的index.php到 www.livedent.pl(无破折号),
- (WWW)live-dent.pl/index_en.php,(WWW)live-dent/index_en.php,(WWW)live-dent.pl/index_en.php和livedent.pl /index_en.php到 www.live-dent(与破折号)。
- (www.)live-dent.pl/index.php, (www.)live-dent/index.php, (www.)live-dent.pl/index.php and livedent.pl/index.php to www.livedent.pl (without dash),
- (www.)live-dent.pl/index_en.php, (www.)live-dent/index_en.php, (www.)live-dent.pl/index_en.php and livedent.pl/index_en.php to www.live-dent (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/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 ^ www.live-dent/ [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 ^ 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 ^ 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 ^ www.live-dent/ [L,R=301]更多推荐
高级htaccess的
发布评论