Htaccess Two different redirects
I have an existing htaccess that works great:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) /default.php
DirectoryIndex index.php /default.php
I want to change this so that all urls starting with / test / go to /test/default.php while keeping all other urls with the existing /default.php .
Example: http://www.x.com/hello.php → http://www.x.com/default.php Example: http://www.x.com/test/hello.php → http: / /www.x.com/test/default.php
In the main folder use the following .htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule .* default.php [L]
DirectoryIndex index.php default.php
In your folder ./test/
(I will assume it is a physical folder) copy and paste the same file .htaccess
.
At first you didn't need the /
default start. Apache will always assume that it is looking in the same directory as the file .htaccess
.
Second, Apache looks backward when looking for a file .htaccess
. So, something in ./test/.htaccess
will rewrite written in ./.htaccess
.
source to share