如何使用htaccess将所有页面重定向到子域上的同一页面?

时间:2013-06-26 11:52:41

标签: .htaccess redirect forwarding

我是htaccess的新手,但我想这样做

例如,我想转发:

www.abc.com/page_1.html 
www.abc.com/folder123/page_a.html  
www.abc.com/folder123/page_b.html 

为:

subdomain.abc.com/page_1
subdomain.abc.com/folder123/page_a     
subdomain.abc.com/folder123/page_b

注意:abc.com(HTML)和subdomain.abc.com(在Wordpress上)位于不同的Web服务器上。

谢谢!

1 个答案:

答案 0 :(得分:1)

RewriteEngine on

RewriteCond %{HTTP_HOST} ^abc\.com$ [OR]

RewriteCond %{HTTP_HOST} ^www\.abc\.com$

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$

RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteRule ^/?$ "https\:\/\/www\.subdomain.abc\.com\/" [R=301,L]