Reputation: 912
I'm using this .htaccess code to redirect the old domain to the new domain:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} test.domain.eu(.*)
RewriteRule (.*) http://test.domain.be/$1 [R=301,L]
This works, also for subdirectories. But in the directory /project, there's a Zend project with the following .htaccess:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
When I go that directory on the old domain, the redirect doesn't work. So I'm guessing these 2 .htaccess files conflict eachother. Does anyone have an idea how to make this work?
Upvotes: 1
Views: 827
Reputation: 12727
Add these 2 rules:
RewriteCond %{HTTP_HOST} test.domain.eu(.*)
RewriteRule (.*) http://test.domain.be/$1 [R=301,L]
to /project
's .htaccess as well.
When an URI request is made, the
.htaccess
in the lower most directory with .htaccess is looked for & used.
Courtesy: @TerryE
.
i.e.
/folder/folder1/folder2
is the requested URI, and lets say all of them has .htaccess
then, folder2's .htaccess
will only be used.
/folder/folder1/folder2
is the requested URI, and lets say only folder1
has a .htaccess
then, folder1's .htaccess
will only be used.
So, do this:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{HTTP_HOST} test.domain.eu
RewriteRule (.*) http://test.domain.be/project/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Upvotes: 2