1

我有一个客户站点,我在其中设置了一些 301 重定向,因为几个页面的 URL 发生了变化。

那里没问题,它们像魅力一样工作。问题是他们将第二个站点设置为第一个站点的子域,并且重定向也被应用于子域。

如何将重定向应用于根目录中的指定 HTML 文件

这是我当前的 HTACCESS 文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# if subdomain then bail out
RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule ^ - [L]

RewriteRule ^home\htm$ http://analystsolutions.com/ [L,NC,R=301]
RewriteRule ^membersolutions\.php$ http://analystsolutions.com/ [L,NC,R=301]
RewriteRule ^institutionalsolutions\.html$ http://analystsolutions.com/institutions [L,NC,R=301]
RewriteRule ^thebook\.html$ http://analystsolutions.com/book [L,NC,R=301]
RewriteRule ^about\.html$ http://analystsolutions.com/about-us [L,NC,R=301]
RewriteRule ^assessment http://analystsolutions.com/equity-research-assessment [L,NC,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

谢谢!

4

1 回答 1

1

用这样的东西改变你的代码:

# if subdomain then bail out
RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule ^ - [L]

RewriteRule ^home\.htm$ http://analystsolutions.com/ [L,NC,R=301]
RewriteRule ^membersolutions\.php$ http://analystsolutions.com/ [L,NC,R=301]
RewriteRule ^institutionalsolutions\.html$ http://analystsolutions.com/institutions [L,NC,R=301]
# rest of your 301 rules here

PS:还要确保这些规则在 WP 代码之前,即RewriteBase在行下方。

于 2013-09-13T12:29:45.733 回答