【发布时间】:2014-08-26 22:09:58
【问题描述】:
我的网站可用/默认有以下记录:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
DocumentRoot /home/git/www/public_html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/git/www/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
ServerAlias *.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteCond %{HTTP_HOST} ^((.*)\.)example.com$
RewriteRule /(.*) /%2/$1
</VirtualHost>
但是,我需要将我的网站重定向到 /(.*)/public_html,该文件位于 index.php 文件中。
如何将请求重定向到子文件夹,以显示子域的内容?
我不能使用 DocumentRoot /home/git/ 因为我有服务器的下一个结构:
/home/git/www/public_html/
public_html 包含其他项目,例如:004、003、001
每个项目也包含 public_html 文件夹,带有 index.php 文件。
当我输入 URL : 004.example.com 时,我需要使用/home/git/www/public_html/004/public_html/index.php 文件。
当我输入 URL : 001.example.com 文件的路径应该是:/home/git/www/public_html/001/public_html/index.php
【问题讨论】:
标签: regex apache .htaccess mod-rewrite subdomain