I have successfully set the DocumentRoot for a given server names:
<VirtualHost *:80>
DocumentRoot "/var/www/html/domain1"
ServerName www.domain1.com
ServerAlias *.domain1.com
#Other directives here
</VirtualHost>
I can't seem to figure out, how to move the subfolders ie."www.domain1.com/contact-us" so it presents index.html located in "/var/www/html/domain1".
I tried adding the alias for the /contact-us in the VirtualHost instructions:
<VirtualHost *:80>
DocumentRoot "/var/www/html/domain1"
ServerName www.domain1.com
ServerAlias *.domain1.com
#Other directives here
Alias /contact-us /var/www/html/domain1
</VirtualHost>
It doesn't work as expected.
I am thinking doing this via .htaccess in the subfolder for the domain1. How would I go around redirecting everything after the domain name to the index.html?
RewriteEngine on
RewriteRule ^subdirectory/(.*)$ /$1 [R=301,NC,L]
RewriteRule ^about-us/(.*)$ /$1 [R=301,NC,L]
RewriteRule ^contact/(.*)$ /$1 [R=301,NC,L]
RewriteRule ^subfolder/(.*)$ /$1 [R=301,NC,L]
Test out this code, make sure the change the folder names.
This must be in your .htaccess in your web directory root folder.
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.