I have multiple websites under the same web server.
My root structure is as following:
./
./site1/
./site2/
./.htaccess
I would like htaccess file to redirect to the correct folder.
If the user navigates to www.site1.com or site1.com it should rewrite the url to go to the ./site1/ folder and if the user navigates to www.site2.com or site2.com it should rewrite the url to go to the ./site2/ folder.
Is there any way to achieve this behaviour?
Thanks in advance.
答案 0 :(得分:1)
Use following code in .htaccess file.
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.com$ [NC]
RewriteRule !^site1/ /site1%{REQUEST_URI} [L,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?site2\.com$ [NC]
RewriteRule !^site2/ /site2%{REQUEST_URI} [L,NC]