简体   繁体   中英

Setup subdomain to point to a specific directory using .htaccess

I want to point the sub domain to different paths using .htacces sub.domain.co.uk point to server path /htdocs_sub/ www.domain.co.uk point to server path /htdocs_www/

I'm trying:

<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>

doesn't respond correctly, just:

"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."
RewriteCond %{HTTP_HOST} ^([a-z\d]+)\.domain\.co\.uk$
RewriteCond %{REQUEST_FILENAME} !^/htdocs_
RewriteRule . /htdocs_%1%{REQUEST_FILENAME} [L]

assumed all paths are relative to the document root

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM