[英]htaccess subdomain with subfolders access
I am trying to rewrite the subdomain request to a subfolder in my server using .htaccess
. 我正在尝试使用.htaccess
将子域请求重写到我服务器中的子文件夹。 I want mail.domain.com
to look into mail
folder located in the root. 我希望mail.domain.com
查看位于根目录中的mail
文件夹。 I am able to achieve this with the below code 我可以使用以下代码实现此目的
RewriteEngine on
RewriteCond %{HTTP_HOST} mail.domain.com$
RewriteCond %{REQUEST_URI} !^/mail
RewriteRule ^(.*)$ /mail/$1 [L]
This WORKS correctly. 这工作正常。 When i browse to mail.domain.com
i am getting the contents of domain.com/mail/index.php
. 当我浏览到mail.domain.com
时,我收到了domain.com/mail/index.php
的内容。
However this doesn't work with the subfolders inside the subdomain. 但是,这不适用于子域内的子文件夹。 ie when i browse to mail.domain.com/installer
it DOESN'T give the contents from domain.com/mail/installer/index.php
. 即,当我浏览到mail.domain.com/installer
它不会从domain.com/mail/installer/index.php
提供内容。 Instead it shows 404 error. 相反,它显示404错误。 I also tried the code from htaccess subdomain pointing . 我也试过了htaccess子域指向的代码。 Somehow I am unable to get the output. 不知怎的,我无法得到输出。 That method also gives the same problem. 该方法也给出了同样的问题。 What am I doing wrong? 我究竟做错了什么?
Note: 注意:
domain.com
& mail.domain.com
aliases. 创建了domain.com
和mail.domain.com
别名。 Edit 编辑
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
When I remove the above wordpress htaccess all works well. 当我删除上面的wordpress htaccess一切正常。 So it is causing 404 error in subdomain subfolders. 因此它在子域子文件夹中导致404错误。 Please help what i can do for both wordpress pretty urls and subdomain subfolders to work? 请帮助我为wordpress漂亮的网址和子域名子文件夹做什么工作?
Note: I am really sorry. 注意:我真的很抱歉。 Wordpress added this via web interface and i failed to notice that. Wordpress通过网络界面添加了这个,我没注意到。
Keep your root .htaccess like this: 保持你的根.htaccess像这样:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =mail.domain.com
RewriteRule ^((?!mail).*)$ mail/$1 [L,NC]
RewriteRule ^(index\.php$|mail) - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.