I have an index.php file in the top level with other files such as "login.php", "register.php" in a folder called includes. The folder hierarchy looks like this:
index.php includes/ register.php login.php css/ style.css images/ image.png
How can I set the url to something like http://www.mydomain.com/register which then from within the index.php page calls (includes) the register.php page?
Is this the best way to go about it?
Thanks
Mike
If your server is Apache: Create on root folder file ".htaccess"
//index.php
You can use apache rewrite rules to do that: (place this in a .htaccess file in the same directoyr than index.php)
And in index.php:
You can write a .htaccess file with something like this:
and the index.php file with:
Of course you can adapt this code to what you need.
Well, so long as the URL stub (i.e. /register) is always going to be the same as the file name you want to include, you could do this using Apache's
mod_rewrite
.However, if you want to change the URL stub to something other than the filename you want to include, why not do this:
using mod_rewrite:
index.php:
EDIT: For security reasons, see also arnouds comment below.