Redirect 301 advice and help needed

  • citysoundman
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 15, 2008
  • Posts: 13
  • Status: Offline

Post July 18th, 2008, 10:58 pm

Hi,

I am having a problem with my .htaccess file using Redirect 301 commands.

I have changed my website, and my new site uses URLs that are different from my old site. FYI my domain name is the same: http://www.citysound.com, but the new site's pages have all different names from my old site.

Since my old site has been indexed by Google etc., I do not want users to link to a page that no longer exists. I have learned that by using a .htaccess file I can write in Redirect 301 lines for each old web page. My idea is to write a separate Redirect 301 line for each old web page (25 pages) and redirect each of them to my new home page: http://www.citysound.com/

As a test I tried a single redirect for one page and it worked fine. But for some reason when I write in more than one Redirect 301 line into my .htaccess file I get Internal Server Errors when I visit ANY page on my site.

This is exactly how I wrote in the code: (The first line by itself works fine. When I add the second line I get the server errors.)

Redirect 301 /cspprojects/index.html http://www.citysound.com/
Redirect 301 /cspstudio/index.html http://www.citysound.com/

I have tried it with a line break between the two lines but no luck.

I'd appreciate any help...

Thanks in advance!
Bob
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 18th, 2008, 10:58 pm

  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post July 18th, 2008, 11:33 pm

What does the Apache error log say ?
Why yes, yes I am.
  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Joined: Jul 18, 2008
  • Posts: 203
  • Loc: Western Australia
  • Status: Offline

Post July 19th, 2008, 1:25 am

It sounds like it should be working, as long as the .htaccess file is in the main directory. I believe seperating by a new line is correct.
A few things - you must use a relative url from the .htaccess's location for the first url, and a full url for the 2nd, eg:

Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/newpage2.html

Make sure you don't make an infinite loop :)

This site might be useful.
  • citysoundman
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 15, 2008
  • Posts: 13
  • Status: Offline

Post July 19th, 2008, 8:41 am

joebert wrote:
What does the Apache error log say ?


The error page is titled 500 Internal Server Error

the page is:

Code: [ Download ] [ Select ]
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
  1. Internal Server Error
  2. The server encountered an internal error or misconfiguration and was unable to complete your request.
  3. Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
  4. More information about this error may be available in the server error log.
  • citysoundman
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 15, 2008
  • Posts: 13
  • Status: Offline

Post July 19th, 2008, 8:46 am

joebert wrote:
What does the Apache error log say ?


Also I just ckecked the error log - here's the most recent part of it
Code: [ Download ] [ Select ]
[Sat Jul 19 00:31:24 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:33:37 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:33:37 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:33:51 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:33:58 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:37:27 2008][alert] [client 74.6.22.175] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:37:50 2008][alert] [client 74.6.22.175] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
[Sat Jul 19 00:38:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
[Sat Jul 19 00:38:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
[Sat Jul 19 00:38:59 2008][alert] [client 74.6.22.175] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
[Sat Jul 19 00:44:37 2008][alert] [client 65.55.208.88] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
[Sat Jul 19 00:44:37 2008][alert] [client 65.55.208.88] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
[Sat Jul 19 00:50:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL
[Sat Jul 19 00:50:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL, referer: http://www.citysound.com/cspprojects/index.html
  1. [Sat Jul 19 00:31:24 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  2. [Sat Jul 19 00:33:37 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  3. [Sat Jul 19 00:33:37 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  4. [Sat Jul 19 00:33:51 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  5. [Sat Jul 19 00:33:58 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  6. [Sat Jul 19 00:37:27 2008][alert] [client 74.6.22.175] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  7. [Sat Jul 19 00:37:50 2008][alert] [client 74.6.22.175] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option redirect
  8. [Sat Jul 19 00:38:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
  9. [Sat Jul 19 00:38:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
  10. [Sat Jul 19 00:38:59 2008][alert] [client 74.6.22.175] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
  11. [Sat Jul 19 00:44:37 2008][alert] [client 65.55.208.88] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
  12. [Sat Jul 19 00:44:37 2008][alert] [client 65.55.208.88] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Illegal option Redirect
  13. [Sat Jul 19 00:50:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL
  14. [Sat Jul 19 00:50:40 2008][alert] [client 66.65.60.4] /data/16/1/155/151/1481151/user/1592605/htdocs/.htaccess: Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL, referer: http://www.citysound.com/cspprojects/index.html
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post July 19th, 2008, 9:16 am

For future reference, any time you get a 500 Server error you're almost always going to get something in the logs like you have in that last post. The 500 is really no more than an indication to look there.

Now as far as the problem, this has got to be the strangest thing I've seen in a long time but I'll be damned if I can't reproduce it every time I try in one of my older existing htaccess files.

In your editor, place your cursor at the very beginning of your second redirects line and backspace untill the two redirects are on the same line with no space inbetween them.

Code: [ Download ] [ Select ]
Redirect 301 /dir/index.html http://domain/Redirect 301 /dir2/index.html http://domain/


Then hit enter so the second redirect drops to a new line.

It should work after that.

It appears to have something to do with line endings because I'm reproducing it with the "IndexOptions" directive and a "Redirect" directive below it.

What operating systems are you editing and hosting on ?
What editors are you using to modify htaccess ?
Why yes, yes I am.
  • citysoundman
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 15, 2008
  • Posts: 13
  • Status: Offline

Post July 19th, 2008, 9:27 am

Joebert,

Thanks for your input.

I just tried your suggestion, but I'm getting the same errors....

I'm editing on Mac OSX. Hosting I believe is UNIX. I'm using a text file within Dreamweaver to make the changes to .htaccess

BTW I just called my server to be sure they use Apache. They said yes, and I should be able to do what I'm attemptimg...
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post July 19th, 2008, 9:35 am

I can't reproduce it if I create a new htaccess & try it there. I can't reliably reproduce it in other existing htaccess files either.
It only happens if I use an existing htaccess I haven't modified in ages. :scratchhead:

You using a Mac makes me more inclined to think it has something to do with line endings & the way the server parses htaccess files.
It seems like it's ignoring whatever line ending is there and assiming the new line is part of the previous directive.

I think you should try a different editor, or play with Dreamweavers line ending settings (if it has any) and see if the problem persists.
Why yes, yes I am.
  • citysoundman
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 15, 2008
  • Posts: 13
  • Status: Offline

Post July 19th, 2008, 9:37 am

OK thanks I will try. It sounds like you are probably right.
  • citysoundman
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 15, 2008
  • Posts: 13
  • Status: Offline

Post July 19th, 2008, 10:32 am

joebert wrote:
You using a Mac makes me more inclined to think it has something to do with line endings & the way the server parses htaccess files.
It seems like it's ignoring whatever line ending is there and assiming the new line is part of the previous directive.

I think you should try a different editor, or play with Dreamweavers line ending settings (if it has any) and see if the problem persists.


Problem solved! Thanks Joebert!

I used a different text editor for the Mac - Text Mate. It does show options for line endings, but I did use their recommended settings. IAC I created a new .htaccess file and then used Dreamweaver to upload it to my server. Interestingly, when I modified the file using Dreamweaver the errors came back. So as long as I modify the file within Text Mate it works fine. Dreamweaver is definitely doing something to the file that is no good!

I reallly appreciate your help! :D
Bob
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post July 19th, 2008, 10:52 am

Good good, this one had me worried for a moment. :D
Why yes, yes I am.
  • joebert
  • Weathered
  • Genius
  • User avatar
  • Joined: Feb 10, 2004
  • Posts: 11879
  • Loc: Clearwater, FL
  • Status: Offline

Post July 19th, 2008, 10:57 am

Now that I think about it, the htaccess file I was trying it with was last edited on a Windows system with Notepad 2 & I'm on Ubuntu Hardy with gedit right now.
Why yes, yes I am.

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: spork and 194 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.