Suppose my domain is foo.com
, I have index.html
in my root directory.
Then if I install a shopping cart in /cart
and it has index.php
as its index page.
How would I change the default index to /cart/index.php
using .htaccess
?
Suppose my domain is foo.com
, I have index.html
in my root directory.
Then if I install a shopping cart in /cart
and it has index.php
as its index page.
How would I change the default index to /cart/index.php
using .htaccess
?
Add the following to make
first.html
your index pageYou can also have multiple files as in :
Here the server will check for files from left to right and use the first one available
So I guess you configuration should be
Since you want ot give more priority to
index.php
when it is found in a directoryUse Redirections:
You can use
Redirect
directive (Mod_Alias). Edit your.htaccess
file and add this line:Or you can use
RedirectPermanent
directive. Edit your.htaccess
file and add this line:Use Rewrite engine:
You can use Mod_Rewrite to achieve the same result as the above. Edit your
.htaccess
file and add these lines:Further reading about Mod_Rewrite: [1]; [2]; [3].
Smart redirection, using PHP:
Edit your
.htaccess
file and add these lines:Create PHP file, called
site-condition.php
, which will redirect the initial request to the first existing file according to this order priority:/cart/index.php
/index.php
/index.html
The content of
site-condition.php
could looks like:According to this example
/cart
must be a sub directory ofDocumentRoot
of the current VHost.Further reading about used PHP functions: [1]; [2]; [3].