SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2012
    Location
    US
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy 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/...ion-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!

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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 EVERYTHING 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 [code]... [/code] 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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2012
    Location
    US
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Code:
    # 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.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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:

    Code:
    # BEGIN Compress text files
    <IfModule mod_deflate.c>
    
    [rant #4]
    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).
    [/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)!
    <FilesMatch "\.(css|js|x?html?|php)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> # END Compress text files # BEGIN Expire headers <IfModule mod_expires.c>
    Ditto
    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>
    Again? :nono:
    <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>
    ... and again ... and again ... and again ...
    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 / # 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
    Why RedirectMatch when you're not using regex?
    #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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2012
    Location
    US
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •