I would like to host my website from /src/index.html
So if you visit my website at https://example.com
, you will see the contents of /src/index.html
(without adding /src/index.html
to the url)
This is currently my file structure
I tried adding the following in my .htaccess file:
RewriteRule ^ src/index.html
That redirects correctly but also redirects all paths linking to any other files (like style.css) to src/index.html making them unusable.
Something like the following would work but it would change the url to example.com/src/index.html
while I would like it to stay at example.com
:
Redirect 301 /index.html /src/index.html
CodePudding user response:
The easiest way is to put your project elsewhere, outside of DocumentRoot
, and make a softlink (ln -s
) to your src
folder in DocumentRoot
.
If you want your project to be the top level (as in your example, http://example.com/
), then you can directly set DocumentRoot
to your src
folder, or replace the DocumentRoot
folder with a softlink as described above.
CodePudding user response:
RewriteRule ^ src/index.html
This naturally rewrites everything. To rewrite requests for the root only then you need to match against ^$
instead.
For example:
RewriteRule ^$ src/index.html [L]