【发布时间】:2016-05-31 05:58:21
【问题描述】:
我想通过 htaccess 动态地将子域指向子目录,而不更改下面显示的 url 和目录列表。
|-- Test (Root Directory) <-- test.com redirects to this folder.
|-- index.php
|
|-- subdomain (Directory)
|
|---- abc (Directory) <-- abc.test.com redirects to this folder.
|------ index.php
|
|---- pqr (Directory) <-- pqr.test.com redirects to this folder.
|------ index.php
|
|---- xyz (Directory) <-- xyz.test.com redirects to this folder.
|------ index.php
我已将以下重写规则应用于点子域。
.htaccess 文件
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.test.com
RewriteRule (.*) http://test.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^test\.com $
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule (.*) /subdomain/$1
RewriteCond %{HTTP_HOST} ^(^.*)\.test.com
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule (.*) /subdomain/$1
我在 htaccess 重写方面不太擅长。
我已经关注这个subdomain on the fly
但我没能成功。非常感谢您的建议。
谢谢。
【问题讨论】:
标签: php apache .htaccess mod-rewrite