By paranoic


2019-03-13 09:21:52 8 Comments

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:

http://www.example.com/subfolder1/subfolder2/product.html

1 comments

@MrWhite 2019-03-13 17:19:04

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.

Related Questions

Sponsored Content

2 Answered Questions

1 Answered Questions

[SOLVED] New Joomla Website - Confused About 301's

4 Answered Questions

[SOLVED] Url redirect in dreamhost without editing htaccess

2 Answered Questions

[SOLVED] 301 redirection from thousands pages to single

1 Answered Questions

1 Answered Questions

[SOLVED] htaccess/cPanel 301 redirects not working for add-on domain

2 Answered Questions

[SOLVED] 301 redirect the home pages but keep sitemap pages same

0 Answered Questions

2 Answered Questions

1 Answered Questions

[SOLVED] Redirecting from a dynamic URL to a prettier/simple URL?

Sponsored Content