2017-06-21 76 views
0

希望你能帮上忙。我需要将所有流量从一个特定的域名转移到另一个永久如简单的搜索和替换.htaccess

domain.com/en/whatever-is-here

domain.co.uk/en/whatever-is-here

我需要找到特定domain.com/en/这将确定这是英文部分,并重定向这个,包括国家文件夹后面的所有内容(在这个例子中不管是什么)。

如果domain.com/de/whatever-is-here叫,没有什么应该发生,当然。

有人可以引导我在正确的方向吗?

我衷心希望得到任何帮助。

Br。布赖恩

UPDATE ********

我已经把建议在以下的.htaccess和它的作品加www电话。我猜这跟剩下的.htaccess是冲突的,但怎么?

# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again 
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution 
# http://www.prestashop.com - http://www.prestashop.com/forums 

<IfModule mod_rewrite.c> 
<IfModule mod_env.c> 
SetEnv HTTP_MOD_REWRITE On 
</IfModule> 

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^www?.domain.com 
RewriteCond %{REQUEST_URI} ^/sv/(.*) 
RewriteRule^http://www.domain.se/sv/%1 [R=301] 


RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule . - [E=REWRITEBASE:/] 
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] 

# Images 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] 
# AlphaImageLoader for IE and fancybox 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] 

# Dispatcher 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^.*$ - [NC,L] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule . - [E=REWRITEBASE:/] 
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] 

# Images 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] 
# AlphaImageLoader for IE and fancybox 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] 

# Dispatcher 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^.*$ - [NC,L] 
RewriteCond %{HTTP_HOST} ^www.domain.dk$ 
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule . - [E=REWRITEBASE:/] 
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] 

# Images 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] 
# AlphaImageLoader for IE and fancybox 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] 

# Dispatcher 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^.*$ - [NC,L] 
RewriteCond %{HTTP_HOST} ^www.domain.se$ 
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] 
</IfModule> 



#If rewrite mod isn't enabled 
ErrorDocument 404 /index.php?controller=404 

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again 

回答

0

尝试用下面的domain.com规则,

RewriteEngine On 
RewriteCond %{HTTP_HOST} www?.domain.com 
RewriteCond %{REQUEST_URI} ^/en/(.*) 
RewriteRule^http://domain.co.uk/en/%1 [R=301] 
+0

阿布舍克您好,感谢您的答复 - domain.com是在同一台服务器上.co.uk,所以我相信我需要寻找对于字符串.com/en/- 它不知道调用/ en /是否来自其中一个或另一个 - 我尝试了另一种方式,并且出现错误 - 重定向过多。 – Brian

+0

请立即尝试编辑。 –

+0

嗨阿布舍克 - 非常感谢帮助我解决我的问题 - 现在工作非常接近。它可以在domain.com/en/whatever被调用时起作用,但当www.domain.com/en/whatever被调用时不起作用。我可以只是复制在相同的www或我需要在规则中添加的东西? BR。 Brian – Brian