我的.htaccess
文件
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(online-shop)/?$ $1/home [L,NC]
RewriteRule ^(my)/?$ $1/home [L,NC]
RewriteRule ^(blog)/(post|tags)/([\w-]+)/?$ index.php?id=$1&type=$2&unique=$3 [L,QSA,NC]
RewriteRule ^(blog)/(archives)/([0-9]{4})/([0-9]{2})?$ index.php?id=$1&type=$2&year=$3&month=$4 [L,QSA,NC]
RewriteRule ^([\w/-]+)/?$ index.php?id=$1 [L,QSA]
因此,以下网址会被重写:
domain.com/home
至domain.com/index.php?id=home
但是,如果我查看子域(cp.domain.com
),我会收到以下错误:
The requested URL /home/user/public_html/index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
所以子域名正在查看域的ROOT目录,但是他们应该在控制面板中设置的目录中查找
一旦删除这行代码:
RewriteRule ^([\w/-]+)/?$ index.php?id=$1 [L,QSA]
子域名开始正常运行
答案 0 :(得分:0)
您可以尝试将最后一条规则限制为仅适用于主域:
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w/-]+)/?$ index.php?id=$1 [L,QSA]