htaccess 301 redirect not working properly
You need to stick with mod_rewrite and not mix mod_rewrite directives with mod_alias directives (Redirect 301
). Before your rewrite rule routing to content.php
, add:
RewriteRule ^example-page$ http://www.domain.com/product/features/example-page [L,R=301]
Sumit Bijvani
Web Developer at WDS India. Sites WDS India Facebook Profile Twitter Account profile for Sumit Bijvani on Stack Exchange, a network of free, community-driven Q&A sites http://stackexchange.com/users/flair/1093989.png
Updated on June 04, 2022Comments
-
Sumit Bijvani over 1 year
I have rewrite URL via htaccess now I want to redirect that URL to another URL.
Below is my rewrite rule, which I am using for short URLRewriteRule ^([a-zA-Z0-9_-]+)$ modules/pages/content.php?page_url=$1 [NC,L]
This is working fine and I can access URL like..
http://www.domain.com/example-page
Now I want to redirecthttp://www.domain.com/example-page
URL tohttp://www.domain.com/product/features/example-page
And my htaccess redirect code is..
redirect 301 /example-page http://www.domain.com/product/features/example-page
This code is working but I'm getting problem.
When I open URL
http://www.domain.com/example-page
it redirect tohttp://www.domain.com/product/features/example-page?page_url=example-page
But instead of it. I want it to redirect to
http://www.domain.com/product/features/example-page
.Please help me regarding this issue.