Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a list of over 100 redirects, nearly all of which seem to be working except for two. I'm using the common format for a htaccess 301 redirect:

redirect 301 /shop/category.cfm/wall-decals http://wallcandyarts.com/wall-decals.html

Near as I can tell, there's nothing wrong this one. The ones I'm having problems with are these two:

redirect 301 /shop/product.cfm/chalkboard-wall-panels http://wallcandyarts.com/chalkboard-decals/chalkboard-panels.html
redirect 301 /shop/category.cfm/chalkboard-decals http://wallcandyarts.com/chalkboard-decals.html

I've read about problems with query strings, but that's not the case here. I also saw when assembling this list of redirects that if the new path ended in "/" that it would cause it to get a similar result of what it's getting with the redirects above. For example, clicking http://www.wallcandyarts.com/shop/product.cfm/chalkboard-wall-panels will give you a "mashed" URL, and I don't know why. Any thoughts?

This is my first foray into anything this heavy with htaccess that didn't involve simply copy/paste, so forgive my ignorance here. Hoping to learn a lot.

Thanks!

UPDATE: Here is the entire htaccess. A lot of stuff that was there prior to me adding 301 directs. The code I added starts at line 181.

http://pastie.org/2371768

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Are the others working for you? I've tried a handful, and each one that I've tried under /shop has thrown my browser under wall-decals.html.

http://wallcandyarts.com/shop/product.cfm/seasons-designer-pillows becomes http://wallcandyarts.com/wall-decals.html/product.cfm/seasons-designer-pillows.

The culprit is your last line:

redirect 301 /shop http://wallcandyarts.com/wall-decals.html

The Redirect directive is based on prefix matching. As the documentation puts it:

Redirect /service http://foo2.bar.com/service
If the client requests http://myserver/service/foo.txt, it will be told to access http://foo2.bar.com/service/foo.txt instead.

This last rule catching all of /shop is clobbering every rule that's targeting something under /shop. I'm not completely sure how the evaluation/priority is handled for Redirect, but RedirectMatch may be a better fit for your needs (or, at least, should be used for that last rule).

RedirectMatch 301 ^/shop/product\.cfm/frames-wall-decals$ http://wallcandyarts.com/wall-decals/frames-decals.html
...
RedirectMatch 301 ^/shop/?$ http://wallcandyarts.com/wall-decals.html
share|improve this answer
    
Thanks, @Shane - I think that's the trick, but it looks as though server-side caching is turned on so I'm not seeing my updates in real-time. Waiting to hear back on that. Do you think I'll need to change every line to RedirectMatch and follow that format? –  Micah Aug 15 '11 at 13:06
    
@Micah As far as what needs to change, the ones on parent directories - where you don't want to affect subdirectories of the location that you're redirecting (like /shop). –  Shane Madden Aug 15 '11 at 14:48
    
Weird thing, after applying the fix as mentioned, I tried the link in Chrome and it worked, and still would not work in Firefox. I cleared cache, still no luck. Going to say it's working, though. Thanks! –  Micah Aug 16 '11 at 1:16
    
Okay, after actually clearing the browser cache properly (before I had only been shift+refreshing - does firefox have a single-page cache?) All working now. Thanks guys. –  Micah Aug 16 '11 at 1:19

First, you should limit all of that code to your httpd.conf file, not htaccess. More of a security threat, since people can download it freely and use it against you. As for the failed redirects... do the destination pages not exist EXACTLY as quoted in the rules?

share|improve this answer
    
You never know with GoDaddy, but most Apache configurations prevent the download of .htaccess. On the redirects; destination pages don't necessary need to exist to redirect to them. –  Shane Madden Aug 15 '11 at 3:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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