htaccess 301 redirect not working properly

11,194

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]
Share:
11,194
Sumit Bijvani
Author by

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, 2022

Comments

  • Sumit Bijvani
    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 URL

    RewriteRule ^([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 redirect http://www.domain.com/example-page URL to http://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 to http://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.