【发布时间】:2015-09-18 09:38:26
【问题描述】:
我有一堆域都指向同一个站点,并且需要能够将 domainalias.com/folder/name 重定向到 website.com/folder/name。
我目前有以下 htaccess,它可以重定向根域,但是一旦我进入子目录或子页面,它就不会重定向:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# Redirect all domains to website.co.uk
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^website.co.uk$ [NC]
RewriteRule ^(.*)$ http://website.co.uk/$1 [L,R=301]
</IfModule>
所以确认一下,我希望人们从http://anydomainalias.co.uk/any/sub/folder 重定向到http://website.co.uk/any/sub/folder。因为它是一个 WordPress 网站,所以我需要它来动态工作。我有 50 多个子域,因此希望避免为每个子域设置一个规则(因此有 !^website.co.uk 规则)。
谢谢。
【问题讨论】:
标签: regex wordpress .htaccess mod-rewrite redirect