Reputation: 138
On our staging server there are different versions of an PHP application. Each version in a different folder, so that the PM can approve feature by feature. The strucure looks like this:
- docroot
- origin
- develop
- origin
- feature
- feature_1
The URLs look like this:
- http://dev.example.com/project/origin/develop
- http://dev.example.com/project/origin/feature/feature_1/
Local development looks like this:
http://project.local/
Now i want to rewrite URLs.
http://project.local/foo/example1/example2
should move to
http://project.local/bar/example1/example2
I tried the following:
RewriteCond %{REQUEST_URI} foo/(.*)
RewriteRule ^foo/(.*)?$ /bar/$1 [R=302,L]
which works as expected on local environment.
On staging server it redirects from:
http://dev.example.com/project/origin/develop/foo/example1/example2
to:
http://dev.example.com/bar/example1/example2
which doesn't work. Is there a way to handle this on local & staging environment?
Upvotes: 1
Views: 78
Reputation: 785276
Issue is that on staging server you are keeping this rule in a .htaccess inside /project/origin/develop
instead of site root .htaccess.
You can use this generic rule that will work in both the places:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.*/)?foo/(.*)$ [NC]
RewriteRule ^ /%1bar/%2 [R=301,L,NE]
Upvotes: 1