Reputation: 53
I want to change root folder directory from www.example.com/index.html (base directory) to a sub directory www.example.com/dist/index.html and serve as www.example.com using .htaccess rules
Upvotes: 0
Views: 334
Reputation:
Example .htaccess file to check:
<IfModule mod_rewrite.c>
RewriteEngine On
# Your new base directory for files - example index.html
RewriteBase /dist/
# Place for your own rules - example with non-www to www, index.html to domain, http to https
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ![0-9]$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^\/index.(html|htm)$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/ [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
</IfModule>
Upvotes: 1