Welcome to WebmasterWorld Guest from 54.145.44.134

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

how to 301 redirect pages within folders?

its not working

     

Lorel

7:49 pm on Aug 11, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have items 1-2-3 folders deep that need to be redirected with a 301 but it's not working. Can someone tell me what's wrong with this code:

RewriteRule ^category/keyword/page-title/$ http://www.example.com/category-page-title.html [R=301,L]

g1smd

8:25 pm on Aug 11, 2012 (gmt 0)

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



Nothing is wrong with the code if you want requests for this URL (with or without www, and with or without query strings):
example.com/category/keyword/page-title/

to be redirectly to
http://www.example.com/category-page-title.html

and original query string (if present) reattached.

lucy24

11:44 pm on Aug 11, 2012 (gmt 0)

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



Is that your actual, literal code or are you paraphrasing? It may help to give some real-life examples. Using example.com, of course, and showing captures, if any.

Lorel

1:37 pm on Aug 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was using fake domain/category/keyword names.

I have them working now except for one line of redirects that takes down the whole site and I can't see anything wrong with it. I"ve checked and double checked the old/new files and the spelling is correct. I even retyped the rule to make sure there wasn't strange code in it.

Can someone tell me why this line takes out the whole website? I only changed the domain on this one:

RewriteRule ^services/anesthesia-free-pet-teeth-cleaning-sacramento/$
http://www.example.com/services-anesthesia-free-pet-teeth-cleaning.html [R=301,L]

I get an "internal server error" when this line is in there but everything works fine if I take it back out.

g1smd

2:02 pm on Aug 12, 2012 (gmt 0)

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



Use the Live HTTP Headers extension for Firefox to see if anything else is returned before the server error occurs.

Lorel

4:45 pm on Aug 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, did that. Here is the result after putting that line (a 301 redirect from old page to new) back in htaccess just long enough to test this. Can you tell what's wrong?

http://www.example.com/

GET / HTTP/1.1
Host: www.EXAMPLE.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: __utma=106706774.1114373890.1344777249.1344777249.1344777249.1; __utmz=106706774.1344777249.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

HTTP/1.1 500 Internal Server Error
Date: Sun, 12 Aug 2012 16:37:13 GMT
Server: Apache
Content-Length: 670
Connection: close
Content-Type: text/html; charset=iso-8859-1

g1smd

4:57 pm on Aug 12, 2012 (gmt 0)

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



There's not an external redirect loop, so there's likely an internal rewrite loop.

Lorel

8:52 pm on Aug 12, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have several similar redirects renaming files and a handful of 410's and the usual non-www to www for the domain which is last in the list.

Everything works fine except this one redirect. If I put it in the whole site goes down. I checked each of the other redirects one by one and they work fine. This is on a new host too.

Any suggestions as to what I should look for that could be causing a loop?

lucy24

11:03 pm on Aug 12, 2012 (gmt 0)

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



I copied & pasted into a text editor, selected Show Invisible characters and got

RewriteRule ^services/anesthesia-free-pet-teeth-cleaning-sacramento/$
http://www.example.com/services-anesthesia-free-pet-teeth-cleaning.html [R=301,L]

with a hard line break in the middle and a trailing space (LETHAL!) at the end. Are either of those in your real Rewrite, or are they artifacts of your own cut-and-paste into the Forums post?

Lorel

2:03 pm on Aug 13, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That must have been it as it's working now.

Thanks Lucy
 

Featured Threads

Hot Threads This Week

Hot Threads This Month