我想使用.htacces将子域指向不同的路径 sub.domain.co.uk指向服务器路径/ htdocs_sub / www.domain.co.uk指向服务器路径/ htdocs_www /
我正在尝试:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.co\.uk$
RewriteCond %{REQUEST_URI} !^/htdocs_sub/
RewriteRule (.*) /htdocs_sub/$1
RewriteCond %{HTTP_HOST} ^www\.domain\.co\.uk$
RewriteCond %{REQUEST_URI} !^/htdocs_www/
RewriteRule (.*) /htdocs_www/$1
</IfModule>
没有正确回应,只是:
"Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
答案 0 :(得分:0)
RewriteCond %{HTTP_HOST} ^([a-z\d]+)\.domain\.co\.uk$
RewriteCond %{REQUEST_FILENAME} !^/htdocs_
RewriteRule . /htdocs_%1%{REQUEST_FILENAME} [L]
假设所有路径都相对于文档根