Welcome to WebmasterWorld Guest from 54.167.155.147

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

redirect not working

   
7:39 pm on Mar 13, 2012 (gmt 0)



I have an issue with a redirect. I moved an index.html file for a sub directory and changed it to another name. The redirect looks like this

redirect 301 /products/ [mydomain.com...]

When I go to visit [mydomain.com...] it redirect to a 403 forbidden page. The url is written funny like this

[mydomain.com...]

All my other redirects work fine. What am I missing?

Thanks in advance
8:14 pm on Mar 13, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



For starters: Please use example.com in all your examples. If you preview a post, you will see the difference.

Bad news: Your Redirect is doing exactly what you told it to do. mod_alias (Redirect by that name) takes the rest of the path and reattaches it to the changed part.

There are two ways to get your Redirect to do what you want it to do. One is to use a RedirectMatch with some capturing. The other is to use mod_rewrite with the [R=301,L] flag. Both ways, you will need to change the syntax a little bit.

Does your htaccess or config file currently use both mod_alias (Redirect or RedirectMatch) and mod_rewrite (RewriteRule)? If yes, change everything to mod_rewrite for safety. If no, use a RewriteMatch.

The 403 that you are seeing is not a "pure" 403. It is the result of an infinite loop: a series of redirects that end up at 403 because the server stops after 10 rounds of doing the same thing. Stop and study your original redirect and you will understand why this is happening.
8:39 pm on Mar 13, 2012 (gmt 0)



Hi Lucy thanks for responding. Im not really sure I understand what to do. Can you please advise.

I believe I'm only using a - mod_rewrite (RewriteRule)

Here is all that's in my htaccess now. Ive taken all the other redirects out to test and still getting the same result

__________________________________

ErrorDocument 404 /404page.html

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

redirect 301 /products/ http://www.example.com/products/example-product.html

_________________________________________

Can you help lead me in the right direction?
9:35 pm on Mar 13, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Do not use Redirect or RedirectMatch anywhere in your htaccess file.

Use RewriteRule for ALL of your rules.

Escape literal periods in RegExatterns.

Make sure the www/non-www redirect is the last ruleset in the file.
9:45 pm on Mar 13, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month





.del
12:01 am on Mar 14, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



OK, lemme nudge you in the right direction.

#1. Your RewriteRule-- which needs to be called by that name-- takes anything containing the element /products/ (no anchors) and redirects it to an URL that contains the element /products/

#2. When you Redirect-- no matter which module does it-- the original request goes all the way outside and starts all over again, as if the server had never seen it before.

Matter of fact, were you really getting a 403 error? I'd expect a browser error message, because the server has no memory and can only recognize rewrites (aka internal redirects).