.htaccess url redirect from one an old page to a new one keeping the root directory same

119 views Asked by At

I have an application whose codebase is deployed inside a folder shop . The URL to the main application is http://myapp/shop/.

One of the links on my page reads

http://myapp/shop/website-design/design-urself.php

which I want to redirect to http://myapp/shop/website-design/index.php

The rule which I am using in my .htaccess file is :

RewriteEngine On
RewriteBase /
RewriteRule ^/website-design/design-urself.php /website-design/index.php [R=301]

But the link is wrongly being getting redirected to http://myapp/website-design/index.php

I tried by removing the leading slash (/) from the urls as :

RewriteRule ^website-design/design-urself.php website-design/index.php [R=301]

but still it doesn't work.

I can understand that probably changing the RewriteBase to shop will solve my problem.

However , the thing here is - going further, the folder name ("shop" in my case) can change . So , in that case I have to again go and modify the .htaccess , which is not desirable.

What is the appropriate RewriteRule I should use in this case?

UPDATE : I have my .htaccess file located at my document root , i.e, inside the folder shop and outside of all other folders residing inside shop.

0

There are 0 answers