301 Redirect still giving 500 error?

I recently moved a blog that was in a subdomain to subdirectory. I followed a tutorial here http://www.seoptimise.com/blog/2008/07/5-wordpress-seo-subdomain-to-subfolder-migration-steps.html.

The code I put in was :
RewriteCond %{HTTP_HOST} ^news.easytoinsureme\.com [NC]
RewriteRule (.*) http://www.easytoinsureme.com/affordable-health-insurance/$1 [R=301,L]

But for some reason this is not redirecting. There are a lot of things in this .htaccess file that may be conflicting, but I do not know enough about them to troubleshoot. Can anyone help me? I am willing to paypal someone who can get me through this!

s83,

First, WHY ask here about code you picked-up elsewhere?

Second, that is not a Redirect 301! That’s because it is mod_rewrite code and the Redirect family of directives belong to mod_alias.

Third, other than a missing \ in the RewriteCond statement (and the simple fact that your :kaioken: EVERYTHING :kaioken: atom will effectively kill your news subdomain), there is nothing in this line code which would generate a 500 error.

Fourth, if you believe that there are conflicts within your .htaccess, you must know that noone can help you with that until you post that code here, too.

Fifth, please put your code in a [noparse]

... 

[/noparse] wrapper as is is preserved in replies and treats the content as code, not text.

Finally, you might still benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

Regards,

DK

I found that tutorial in a google search, and out of all of them it seemed the most straight forward. I am new to any redirects and htaccess stuff, I only attempted because it seemed doable. The 500 comes when I search google for an old blog post thats using the subdomain. If I type in the old url, news.easytoinsureme.com, it also doesnt redirect to new location of easytoinsureme.com/affordable-health-insurance. Here is the whole code, I only added the two lines I mentioned.

# BEGIN Compress text files

<IfModule mod_deflate.c>

  <FilesMatch "\\.(css|js|x?html?|php)$">

    SetOutputFilter DEFLATE

  </FilesMatch>

</IfModule>

# END Compress text files



# BEGIN Expire headers

<IfModule mod_expires.c>

  ExpiresActive On

  ExpiresDefault "access plus 1 seconds"

  ExpiresByType image/x-icon "access plus 2592000 seconds"

  ExpiresByType image/jpeg "access plus 2592000 seconds"

  ExpiresByType image/png "access plus 2592000 seconds"

  ExpiresByType image/gif "access plus 2592000 seconds"

  ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"

  ExpiresByType text/css "access plus 604800 seconds"

  ExpiresByType text/javascript "access plus 216000 seconds"

  ExpiresByType application/x-javascript "access plus 216000 seconds"

  <FilesMatch "\\\\.(x?html?)$">

  ExpiresByType text/html "access plus 600 seconds"

  </FilesMatch>

  ExpiresByType application/xhtml+xml "access plus 600 seconds"

</IfModule>

# END Expire headers



# BEGIN Cache-Control Headers

<IfModule mod_headers.c>

  <FilesMatch "\\\\.(ico|jpe?g|png|gif|swf)$">

    Header set Cache-Control "max-age=2592000, public"

  </FilesMatch>

  <FilesMatch "\\\\.(css)$">

    Header set Cache-Control "max-age=604800, public"

  </FilesMatch>

  <FilesMatch "\\\\.(js)$">

    Header set Cache-Control "max-age=216000, private"

  </FilesMatch>

  <FilesMatch "\\\\.(x?html?)$">

    Header set Cache-Control "max-age=600, private, must-revalidate"

  </FilesMatch>

</IfModule>

# END Cache-Control Headers



# BEGIN Turn ETags Off

<IfModule mod_headers.c>

  Header unset ETag

</IfModule>

FileETag None

# END Turn ETags Off



# BEGIN Remove Last-Modified Header

# <IfModule mod_headers.c>

#  Header unset Last-Modified

# </IfModule>

# END Remove Last-Modified Header



Options -Indexes



RewriteEngine on

RewriteBase /

# Adds a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ http://www.easytoinsureme.com/$1/ [L,R=301,NC]

RewriteCond %{HTTP_HOST} ^easytoinsureme\\.com [NC]
RewriteRule ^(.*)$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]

RewriteCond %{HTTP_HOST} ^new\\.easytoinsureme\\.com [NC]
RewriteRule ^(.*)$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]

RewriteCond %{HTTP_HOST} ^news.easytoinsureme\\.com [NC]
RewriteRule (.*) http://www.easytoinsureme.com/affordable-health-insurance/$1 [R=301,L]

#RewriteRule ^blogs/(.*)$ http://news.easytoinsureme.com/ [R=permanent,L]
#RewriteRule ^articles/(.*)$ http://news.easytoinsureme.com/ [R=permanent,L]
RewriteRule ^States/(.*)0$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]
RewriteRule ^(.*)0$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]
RewriteRule ^States/(.*)$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]
RewriteRule ^easytoinsureme\\ pages/(.*)$ http://www.easytoinsureme.com/ [R=permanent,L]
RewriteRule ^quote/(.*)$ http://www.easytoinsureme.com/-quotes.html [R=permanent,L]


RewriteCond %{REQUEST_URI} ^/index.html$

RewriteRule ^index.html$ / [R,L]

ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

redirect 301 http://new.easytoinsureme.com http://www.easytoinsureme.com

redirect 301 /autoquoteform.html /health-insurance-quotes.html
redirect 301 /flhealthinsurance.html /florida-health-insurance.html
redirect 301 /floridahealthinsurance.html /florida-health-insurance.html
redirect 301 /virgina-health-insurance.html /virginia-health-insurance.html
redirect 301 /ohiohealthinsurance.html /ohio-health-insurance.html
redirect 301 /health-insurance-ohio.html /ohio-health-insurance.html
redirect 301 /pennsylvaniahealthinsurance.html /pennsylvania-health-insurance.html
redirect 301 /pennsylvanialifeinsurance.html /pennsylvania-health-insurance.html
redirect 301 /pennsylvania_health_insurance.html /pennsylvania-health-insurance.html
redirect 301 /health-insurance-pennsylvania.html /pennsylvania-health-insurance.html
redirect 301 /medical-mutual-ohio.html /medical-mutual.html
redirect 301 /individual-health-insurance-company.html /health-insurance-quote.html
redirect 301 /individual-health-insurance-quotes-form.html /health-insurance-quotes.html
redirect 301 /cover-florida-health-insurance.html /florida-health-insurance.html
redirect 301 /health-insurance-florida.html /blue-cross-blue-shield.html
redirect 301 /links.html http://www.easytoinsureme.com
redirect 301 /life-insurance.html http://www.easytoinsureme.com
redirect 301 /blue-cross-blue-shield-pennsylvania.html /highmark-blue-cross-blue-shield.html
redirect 301 /individual-health-insurance-states.html /individual-health-insurance.html
redirect 301 /adult_basic.html /pennsylvania-health-insurance.html
redirect 301 /Connecticut-health-insurance.html /connecticut-health-insurance.html
redirect 301 /chip.html http://www.easytoinsureme.com
redirect 301 /health-insurance-quotes.php /health-insurance-quotes.html
redirect 301 /Mississippi-health-insurance.html /mississippi-health-insurance.html

#redirectMatch 301 ^/articles/ http://news.easytoinsureme.com/
#redirectMatch 301 ^/blogs/ http://news.easytoinsureme.com/
redirectMatch 301 ^/Health-Insurance/ http://www.easytoinsureme.com/individual-health-insurance.html
redirectMatch 301 ^/Health-Insurance-Company/ http://www.easytoinsureme.com/health-insurance-quote.html
#redirectMatch 301 ^/States/ http://www.easytoinsureme.com/individual-health-insurance.html


I will definitely look at your tutorial, thank you.

satori,

IMHO, when you attempt to follow someone’s tutorial on any subject and have difficulties, the best course of action is to ask the source.

A review of your .htaccess code:

# BEGIN Compress text files
<IfModule mod_deflate.c>
[indent][rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result.  Asking Apache to confirm the existence of ANY module with an <IfModule> ... </IfModule> wrapper is the same thing in the webmaster world.  DON'T BE AN IDIOT!  If you don't know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache's resources (and should NEVER be allowed on a shared server).[/indent][/rant 4]

That means test ONCE then remove the @#$% wrappers. Not doing that is an abuse of the server (and should get your removed from a shared server)![/indent]
  <FilesMatch "\\.(css|js|x?html?|php)$">
    SetOutputFilter DEFLATE
  </FilesMatch>
</IfModule>
# END Compress text files

# BEGIN Expire headers
<IfModule mod_expires.c>
[indent]Ditto[/indent]
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType image/x-icon "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
  <FilesMatch "\\\\.(x?html?)$">
  ExpiresByType text/html "access plus 600 seconds"
  </FilesMatch>
  ExpiresByType application/xhtml+xml "access plus 600 seconds"
</IfModule>
# END Expire headers

# BEGIN Cache-Control Headers
<IfModule mod_headers.c>
[indent]Again? :nono:[/indent]
  <FilesMatch "\\\\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </FilesMatch>
  <FilesMatch "\\\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </FilesMatch>
  <FilesMatch "\\\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </FilesMatch>
  <FilesMatch "\\\\.(x?html?)$">
    Header set Cache-Control "max-age=600, private, must-revalidate"
  </FilesMatch>
</IfModule>
# END Cache-Control Headers

# BEGIN Turn ETags Off

<IfModule mod_headers.c>
[indent]... and again ... and again ... and again ...[/indent]
  Header unset ETag
</IfModule>

FileETag None

# END Turn ETags Off
# BEGIN Remove Last-Modified Header
# <IfModule mod_headers.c>
#  Header unset Last-Modified
# </IfModule>
# END Remove Last-Modified Header

Options -Indexes

RewriteEngine on

[COLOR="#FF0000"]RewriteBase /[/COLOR] # where's the mod_alias redirect this is UNDOing?

# Adds a trailing slash to directories
[indent]VERY bad "technique" for a webmaster as this "confuses" browsers looking for relative links.[/indent[
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteCond %{REQUEST_URI} !\\..+$ # does not end with an extension - does this mean it's a directory? Why not use -d?
RewriteCond %{REQUEST_URI} !/$ # this ANDed condition will always match on an Apache 2.x server
RewriteRule ^(.*)$ http://www.easytoinsureme.com/$1/ [L,R=301,NC] # No case? Why? {REQUEST_URI} is case sensitive.

RewriteCond %{HTTP_HOST} ^easytoinsureme\\.com [NC]
RewriteRule ^(.*)$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]

RewriteCond %{HTTP_HOST} ^new\\.easytoinsureme\\.com [NC]
RewriteRule ^(.*)$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC] # that looks okay except for the No Case flag

RewriteCond %{HTTP_HOST} ^news.easytoinsureme\\.com [NC]
RewriteRule (.*) http://www.easytoinsureme.com/affordable-health-insurance/$1 [R=301,L]

#RewriteRule ^blogs/(.*)$ http://news.easytoinsureme.com/ [R=permanent,L]
#RewriteRule ^articles/(.*)$ http://news.easytoinsureme.com/ [R=permanent,L]
RewriteRule ^States/(.*)0$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]
RewriteRule ^(.*)0$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]
RewriteRule ^States/(.*)$ http://www.easytoinsureme.com/$1 [R=permanent,L,NC]
RewriteRule ^easytoinsureme\\ pages/(.*)$ http://www.easytoinsureme.com/ [R=permanent,L]
RewriteRule ^quote/(.*)$ http://www.easytoinsureme.com/-quotes.html [R=permanent,L]


RewriteCond %{REQUEST_URI} ^/index.html$

RewriteRule ^index.html$ / [R,L] # Remove index.html? OMG! Why?

ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

redirect 301 http://new.easytoinsureme.com http://www.easytoinsureme.com

redirect 301 /autoquoteform.html /health-insurance-quotes.html
redirect 301 /flhealthinsurance.html /florida-health-insurance.html
redirect 301 /floridahealthinsurance.html /florida-health-insurance.html
redirect 301 /virgina-health-insurance.html /virginia-health-insurance.html
redirect 301 /ohiohealthinsurance.html /ohio-health-insurance.html
redirect 301 /health-insurance-ohio.html /ohio-health-insurance.html
redirect 301 /pennsylvaniahealthinsurance.html /pennsylvania-health-insurance.html
redirect 301 /pennsylvanialifeinsurance.html /pennsylvania-health-insurance.html
redirect 301 /pennsylvania_health_insurance.html /pennsylvania-health-insurance.html
redirect 301 /health-insurance-pennsylvania.html /pennsylvania-health-insurance.html
redirect 301 /medical-mutual-ohio.html /medical-mutual.html
redirect 301 /individual-health-insurance-company.html /health-insurance-quote.html
redirect 301 /individual-health-insurance-quotes-form.html /health-insurance-quotes.html
redirect 301 /cover-florida-health-insurance.html /florida-health-insurance.html
redirect 301 /health-insurance-florida.html /blue-cross-blue-shield.html
redirect 301 /links.html http://www.easytoinsureme.com
redirect 301 /life-insurance.html http://www.easytoinsureme.com
redirect 301 /blue-cross-blue-shield-pennsylvania.html /highmark-blue-cross-blue-shield.html
redirect 301 /individual-health-insurance-states.html /individual-health-insurance.html
redirect 301 /adult_basic.html /pennsylvania-health-insurance.html
redirect 301 /Connecticut-health-insurance.html /connecticut-health-insurance.html
redirect 301 /chip.html http://www.easytoinsureme.com
redirect 301 /health-insurance-quotes.php /health-insurance-quotes.html
redirect 301 /Mississippi-health-insurance.html /mississippi-health-insurance.html

#redirectMatch 301 ^/articles/ http://news.easytoinsureme.com/
#redirectMatch 301 ^/blogs/ http://news.easytoinsureme.com/
redirectMatch 301 ^/Health-Insurance/ http://www.easytoinsureme.com/individual-health-insurance.html
redirectMatch 301 ^/Health-Insurance-Company/ http://www.easytoinsureme.com/health-insurance-quote.html
[indent]Why RedirectMatch when you're not using regex?[/indent]
#redirectMatch 301 ^/States/ http://www.easytoinsureme.com/individual-health-insurance.html


OMG! Too many little things for me to whine about! I hope the tutorial helped.

Regards,

DK

Wow, I had no idea this was so bad. First off, I am thankful to say I did not write any of that. A friend asked if I could move his blog since I work with Wordpress. I found the two lines of code that were supposed to be put in htaccess when I was done moving it. It seemed like those code lines were pretty similar in every tutorial I saw on moving blogs. The company that originally built the website wrote all that .htaccess stuff, so thats why I tried asking for help.

satori,

Please remember that I’m rather pedantic about mod_rewrite (and all Apache) code as it’s better for members to learn the proper way to manage their server (whether it be by httpd.conf, httpd-vhosts.conf or .htaccess) than to play “script kiddie” and use “crap code.”

In your case, I understand that you inherited the code but there’s just too much wrong with it for me to waste the time to “correct” it all. If that code works, then use the old admonition: “If it ain’t broke, don’t fix it.” That said, if I were your host, you’d not be a client on a shared server - I’d move you to a VPS or dedi rather than allow you to adversely impact other clients. (How’s that for a rant?)

Regards,

DK