子域 htaccess 索引



我有这个结构

/
/-log
/-shop
/-wwwroot
/--shop
/--shop/-index.html
/--wp-content
/-- and so on

我想将每个浏览 shop.mysite.com 的访问者重定向到/--shop/-index.html 文件 (shop.mysite.com/index.html)。就像现在一样,他们将 mysite.com 进入"正常"页面。

我有正确的通配符集。

我的.htaccess看起来像这样(普通的Wordpress)。

# 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>
# END WordPress

我该如何解决这个问题?

您需要

RewriteBase /之后立即添加它

RewriteCond %{HTTP_HOST} ^shop.mysite.com$ [NC]
RewriteRule ^$ /shop/index.html [L]

这只会 http://shop.mysite.com/shop/index.html 提供文件,如果要将所有请求重定向到 shop.mysite.com 主机,则需要创建一个正则表达式并将其指向/shop 中的文件。


这里应该使用正则表达式吗?这应该是什么样子?

您可以在上述规则下方添加以下内容:

RewriteCond %{HTTP_HOST} ^shop.mysite.com$ [NC]
RewriteCond %{REQUEST_URI} !^/shop/
RewriteRule ^(.*)$ /shop/$1 [L]

最新更新