我希望将“存档”的子域附加到点击的网址,以允许他们转到新的存档网站,而不是常规网站。您可以访问http://archives.thegatepost.com网站,了解我的目标。
重写为:#http://archives.thegatepost.com/news/GP_pgs1-4.pdf
这需要能够在.htaccess文件中完成
不担心301或类似的东西。如果它可以做到SEO友好,所有更好,如果不是没有损失。
我尝试了Apache mod_rewrite domain to subdomain?,但它无效:
RewriteEngine On
RewriteCond %{http_host} ^thegatepost.com/archives [nc]
RewriteRule ^(.*)$ http://www.thegatepost.com/archives/$1 [R=301,NC]
RewriteCond %{HTTP_HOST} ^www\.thegatepost\archives\.com$ [NC]
RewriteRule ^archives/([a-z0-9\-_\.]+)/?(.*)$ http://$1.thegatepost.com/archives/$2 [QSA,NC,R,L]
答案 0 :(得分:0)
在www.thegatepost.com
域
RewriteEngine on
RewriteBase /
#if request on www.gatepost.com
RewriteCond %{HTTP_HOST} ^www\.thegatepost\.com$ [NC]
#and for a resource in the /news/ directory
RewriteCond %{REQUEST_URI} ^/news/ [NC]
#redirect them to same resource on the archives.thegatepost.com
RewriteRule (.*) http://archives.thegatepost.com/$1 [L,R=301]