I have a website, say http://mysite.com. I would like to put index.php in a subdirectory, public_html/mysubdir/index.php. I would like public_html/mysubdir/index.php to get executed when the user goes to http://mysite.com. And I would like the url to continue to read http://mysite.com. Is this possible?
I have a website, say http://mysite.com . I would like to put index.php in
Share
Rewrite rules may be overkill for this depending on what you want. For just your main index page, this will work…
Simply adding this one line to your
.htaccessfile:It will display the page located at
mysubdir/index.phpwhile simply showinghttp://mysite.comin the URL.I use this method myself. While all of my pages are located in the same subdirectory, the home page is displayed with my domain name by itself (
http://www.mysite.com). All other pages show the full URL.If you also have
indexpages within deeper subdirectories and want those to come up by default within the subdirectory.Example:
If you want this page:
http://mysite.com/mysubdir/anothersub/index.phpto come up with this URL:
http://mysite.com/mysubdir/anothersub/Then modify the line with another
index.phplike this…What this does is tell the server to look for files with those names in that same order. If it can’t find the first, it tries the second, and so on.
When you’re inside your root at
/it finds and then displaysmysubdir/index.php.When you’re inside another subdirectory like
/mysubdir/anothersub/, it can’t find anything namedmysubdir/index.phpso it goes to the next item and displaysindex.php