I have one product page indexed on Google but that link does not exist anymore and hits 404 page.

What I want to do is to redirect that link in .htaccess to another product page since it ranks very high. So I tryed almost every option and combination i.e.

Redirect 301 /old-page.html /new-page.html

Redirect 301 http://www.example.com/old-page.html   http://www.example.com/new-page.html

etc. but none of those works for me.

Could anyone help me, is there any other solution or practice how to redirect thispage to another.

Btw. my links path contain 2 subfolders each like:

  • Are you editing the .htaccess file in the document root of your site? Do you have other directives in your .htaccess file? If so, please include your entire .htaccess file in your question. Do you have any other .htaccess files in subdirectories? "my links path contain 2 subfolders" - Although neither of your example directives include this?
    – MrWhite
    Commented Mar 13, 2019 at 10:06
  • Thx. for respond @MrWhite ... this is my htaccess file codepile.net/pile/rB585mzm yes i am editing htaccess file in root. i do have other htaccess file in my subdirectories, dont know how many... but i do not have htaccess file in subfolder of pages i want to redirect. actually those are nonexisting subfolders since URL is generated dynamically
    – paranoic
    Commented Mar 13, 2019 at 10:29
  • I can't see where you have placed these directives in your .htaccess file (in your code dump at codepile.net)? codepile.net also seems to have parsed the file in some way and appears to be hiding part directives (perhaps because it has been formatted as HTML)? The "raw" option on that site is not working. Please add the code to your question, rather than link to an external site.
    – MrWhite
    Commented Mar 13, 2019 at 12:15
  • sorry @MrWhite ... i just added a code to my question
    – paranoic
    Commented Mar 13, 2019 at 12:31
  • What version of Apache server is running for your site? Redirect 301 /old-page.html /new-page.html should work for version 2.4 but not for version 2.2. Redirect 301 http://www.example.com/old-page.html http://www.example.com/new-page.html isn't valid syntax for any version of Apache. Commented Mar 13, 2019 at 14:45

1 Answer 1


Without knowing the exact URL you are trying to redirect it's difficult to say whether you were experiencing a conflict with your existing directives or not. Although, if you were still seeing a 404 then your first directive:

Redirect 301 /old-page.html /new-page.html

...should have still "worked" (providing you are on Apache 2.2.6+)

However, since you already have a lot of existing mod_rewrite directives, you should really be using a mod_rewrite RewriteRule for this redirect, instead of a mod_alias Redirect. The reason being that mod_rewrite executes before mod_alias, regardless of the order of directives in .htaccess, so you can get unexpected conflicts (you already have many mod_rewrite redirects) or at the very least unnecessary additional processing before the redirect.

Try something like the following at the very top of your .htaccess file:

RewriteRule ^subfolder/old-page\.html$ https://www.example.com/subfolder/new-page.html [R=302,L]

Note there is no slash prefix on the RewriteRule pattern. I've included https and the full URL in the substitution since you do have a HTTP to HTTPS redirect later in the file.

I would add, however, that your directives do seem a bit muddled in that you have rewrites before redirects and your canonical non-www to www and HTTP to HTTPS redirects are at the very end so may get skipped entirely.

  • thank you @MrWhite. the second solution worked by me perfectly.
    – paranoic
    Commented Mar 25, 2019 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.