【发布时间】:2017-10-17 19:53:22
【问题描述】:
我正在努力正确配置我的 .htaccess,以便为特定子域设置子域重定向。我想将子域重定向(而不是屏蔽)到特定页面并多次重复此配置。
我托管在当前使用 Cloud DNS 的 Google Compute Engine 上(用于托管在 Godaddy 上,其中子域管理非常简单)
before:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
after:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sat.theteachertutors.com$ [NC]
RewriteRule ^(.*)$ /private-sat-act-tutoring/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我尝试了上面的配置,但重定向不起作用。目标网址为:https://www.theteachertutors.com/private-sat-act-tutoring/ 任何指导/提示将不胜感激。我已经搜索了其他示例,但根本无法使用此配置,即:http://sat.theteachertutors.com
谢谢
【问题讨论】:
-
Apache 2.2 版还是 2.4 版?您是否尝试在重写规则中添加“R”标志?像这样:
RewriteRule ^(.*)$ /private-sat-act-tutoring/$1 [R,L] -
嗨 - 我按照下面的方法尝试过,但仍然没有运气......
标签: php apache .htaccess redirect mod-rewrite