简体   繁体   English

htaccess-301域重定向

[英]Htaccess - 301 domain redirection

I want to redirect my old domain to the new one. 我想将旧域重定向到新域。 Actually my site is under www_olddomain_pl/index.php and english version under www_olddomain_com/index_en.php 实际上,我的网站在www_olddomain_pl / index.php下,英文版本在www_olddomain_com / index_en.php下

What I want to do? 我想做的事?

olddomain_pl -> www_new_pl
www_olddomain_pl -> www_new_pl
odldomain_com -> www_new_com
www_olddomain_com -> www_new_com

And redirect from index to without index. 并从索引重定向到无索引。 What I actually have? 我到底有什么?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)olddomain_pl(.*) [NC]
RewriteRule ^(.*)$ http://www_olddomain_pl/$1 [R=301,L]
RewriteRule ^index.php$ http://www_new_pl/ [R=301,L]

RewriteCond %{HTTP_HOST} ^(.*)olddomain_com(.*) [NC]
RewriteRule ^(.*)$ http://www_new_com/$1 [R=301,L]

I don't know what to do. 我不知道该怎么办。

EDIT: One more: Actually I've two version of my site - polish and english. 编辑: 一个:实际上,我有两个版本的网站-波兰语和英语。 Polish version is under olddomain_pl/index.php English version is under olddomain_pl/index_en.php 波兰语版本位于olddomain_pl / index.php下英文版本位于olddomain_pl / index_en.php下

I want have: Polish version under new_pl English version under new_com 我要:new_pl下的波兰语版本new_com下的英语版本

So I need redirect from without www to with www and from index.php or index_en.php to without that. 因此,我需要从无www重定向到www和从index.php或index_en.php重定向到没有www。

You can use this rule: 您可以使用以下规则:

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]

EDIT: As per comment: 编辑:根据评论:

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

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

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