.htcaccess redirects ONLY root ("/") to a subfolder

I have a website that is structured this way:

/about

/ Css /

/index/index.php

/ Js /

/index.php

index.php uses PHP redirection to index / index.php

I want to create an .htaccess rewrite rule so that /index/index.php, BUT / etc. is displayed when accessing the root. remains the same.

+3
source share
2 answers

If you have mod_rewrite, this should work:

RewriteEngine on
RewriteRule ^$ /index/index.php [L]

This will only match / (which it sees as empty) and internally redirected to / index / index.php

+2
source

Next, index / index.php will be displayed / displayed as its index file

DirectoryIndex index/index.php

.htaccess /

0

Source: https://habr.com/ru/post/1731828/


All Articles