Forum Moderators: phranque

Message Too Old, No Replies

htaccess Redirect question

         

JoeVodkaSauce

9:28 pm on Nov 5, 2007 (gmt 0)

10+ Year Member



I'm trying to setup a permanent (301) redirect in my htaccess file but it isn't working. The line I've added is as follows:

Redirect 301 /cff/StoreLocations.html http://www.example.com/info/store_locations.html

When I test this in a browser it doesn't work, I get a 404 page not found error). I've got a couple of other redirects which DO work - just the last one does not. Any thoughts on this would be appreciated.

DirectoryIndex index.html /mm5/merchant.mvc
Redirect 301 /Merchant2 http://www.example.com/
Redirect 301 /cff http://www.example.com/
Redirect 301 /Merchant2/merchant.mvc http://www.example.com/

[edited by: encyclo at 11:23 pm (utc) on Nov. 5, 2007]
[edit reason] switched to example.com [/edit]

jd01

9:42 pm on Nov 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check the target URL...

Copy and paste the location as you have it on the right side of the rule.
For some reason, it appears the page is missing...

Maybe it was not uploaded to the correct directory, or there is a space in the target URL rather than a hyphen or underscore?

Justin

JoeVodkaSauce

10:28 pm on Nov 5, 2007 (gmt 0)

10+ Year Member



Actually the url is correct - I didn't think we're allowed to post real website URL's here so I changed it for the post (i.e. yourdomain.com).

I double-checked the URL and also the underscores - the url I'm trying to redirect too is valid.

Thanks for the try though.

Marcia

10:40 pm on Nov 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>I've got a couple of other redirects which DO work

What's the order of those redirects involving the /cff directory? It looks like there might be a conflict/sequence issue

[httpd.apache.org...]

First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.

For this reason, when two or more of these directives apply to the same sub-path, you must list the most specific path first in order for all the directives to have an effect.

JoeVodkaSauce

1:05 am on Nov 6, 2007 (gmt 0)

10+ Year Member



I actually did some more reading and although I'm no expert I think I've found a better way of doing this:

RedirectMatch 301 ^/Merchant2/(.*) http://www.example.com/

That seems to work well for my needs. It takes care of the bigger issue of other subdirectories and files which I don't want to/can't name for redirection. Thanks all for you help! and I think the last post was right - something about the order seems to have been in conflict.