Forum Moderators: phranque

Message Too Old, No Replies

Worked fine on test site, live site now has mysterious 500 errors

         

laurenji

3:59 pm on Feb 2, 2015 (gmt 0)

10+ Year Member



So, I really appreciate everyone's help on the .htaccess file I've been working on ( see thread [webmasterworld.com...] for original questions ) Thanks to the help I got, the .htaccess file I created worked perfectly on the test server.

However, when I implemented it to the live server, things did not go as planned, and I have no idea where to even start debugging it, as I don't know a whole lot about .htaccess files and even less about servers. Let me see if I can describe the problem properly.

First off, "example.com" is the original website, and "example.org" is the website I'm trying to redirect to. It's a completely different URL from the old site, not a .org version of the old URL, but I needed two variations of "example.com".

Here is the line of code in my .htaccess that pertains to the following URL examples:

RewriteRule c-GinoAns_East http://www.example.org/product-category/deep-dish/? [R=301,L]


Here are a bunch of different URLs that this rule applies to, and which all redirected perfectly on the test server, along with the way that they are redirecting now on the live server:

  • http://www.example.com/a-store/c-GinoAns_East.shtml --> 301 Redirect to http://www.example.org/product-category/deep-dish/ (works perfectly)
  • http://example.com/cgi-local/SoftCart.exe/a-store/c-GinoAns_East.shtml?E+scstore+ginos%EF%BC%89 --> 302 redirect to http://www.example.org/cgi-local/SoftCart.exe/product-category/deep-dish/index.html?L+scstore+yvvl4061ginos)ff006100+1422904538 (This is close, but it shouldn't be appending the query string since I used a ? at the end of the rule, and also I don't know why it's a 302 instead of a 301)
  • http://example.com/cgi-local/SoftCart.exe/a-store/c-GinoAns_East.shtml --> 500 Internal Server Error
  • http://example.com/cgi-local/SoftCart.exe/a-store/c-GinoAns_East.shtml?L scstore rhyw2735ginosff6ea96e --> 500 internal server error.

    Do any of you have any ideas for why these different results might be happening? My only thought was that there's some sort of ecommerce software that was generating the site originally (the /cgi-local/SoftCart.exe part), and that it's running before the .htaccess file. But that seems weird, because wouldn't the server run all of the .htaccess and configuration files before any installed software?

    Now, the other problem is, where to put the .htaccess file. When I first log into the server through FTP, I get various folders, including:

    cgi-local

    htdocs


    and some other ones (bin, conf, dev, etc, ftp, logs, merchant, pub, usr). Now, when I try to put the .htaccess in this main folder, the transfer fails (I get a "permission denied" error.) The .htaccess was originally placed (not by me) in the htdocs folder, where I appear to have appropriate permissions. I was wondering if the fact that the file is in the htdocs folder means that it doesn't affect anything in the cgi-local folder, so I put the .htaccess file in there too. However, this did not change any of the results. So now I'm not sure what to do.

    Anyways, I would really appreciate any help here, because I'm completely at a loss for what to do, or if there's anything I CAN do.
  • lucy24

    5:20 pm on Feb 2, 2015 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



    The usual location for an htaccess file is in the same folder that contains the site's front page ("index.html" or similar)-- the same place you put robots.txt and favicon.ico, so look there. This is especially important if you've got two or more sites living on the same server.

    http://example.com/cgi-local/SoftCart.exe/a-store/c-GinoAns_East.shtml --> 500 Internal Server Error

    Off-the-top-of-my-head explanations:
    (a) The new server has different PathInfo settings, leading to different handling of the part after the ".exe" extension.
    (b) The htaccess file is seen by sites other than the one it was intended for.

    In your examples, the request that behaves as intended is for "www.example.com" while the others are "example.com" without www. Was this just an artifact of posting, or were the hostnames really different?

    http://example.com/cgi-local/SoftCart.exe/a-store/c-GinoAns_East.shtml?E+scstore+ginos%EF%BC%89
    --> 302 redirect to
    http://www.example.org/cgi-local/SoftCart.exe/product-category/deep-dish/index.html?L+scstore+yvvl4061ginos)ff006100+1422904538

    This one frankly worries me the most, because how is that path info getting into the target? It's what you would expect to see if you were capturing for reuse, OR if the rule were written in mod_alias. In fact on closer inspection it looks very much like an internal rewrite that has been sent back out into the world as an external redirect.

    Look closely at any and all htaccess files located anywhere in your filepaths. See if there are any mod_alias directives (Redirect by that name). Can we assume the site itself (your shopping-cart software and similar) is not issuing redirects on its own behalf?

    not2easy

    8:30 pm on Feb 2, 2015 (gmt 0)

    WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



    I hadn't heard of the cart in question, but a search for SoftCart.exe brings up some scary results - things people allow to be indexed.. They all have that cart in
    ../cgi-bin/STORE/letter-store/
    which looks kind of like a virtual directory set-up. I would check documentation for the install.

    By all means, lucy24 is right about where to put it, you don't want copies of .htaccess where they don't belong. You can expect the unexpected with a copy in
    /cgi-local/
    and there should not be URLs with and without the www if things are in the right place with the right settings.

    laurenji

    8:45 pm on Feb 2, 2015 (gmt 0)

    10+ Year Member



    Ooo, good catch on the www vs non www versions . . . I'll have to look. All these URLs that I'm testing are scraped from Google and MajesticSEO, and have a mix of the www and non-www versions, but you're right that in a perfect .htaccess file, that shouldn't make a difference.

    The other very, very strange thing about this website is that when I click on the "htdocs" folder, there's another set of folders identical to the folders above it, and when I click on the next htdocs folder, there's yet another set of identical folders . . . I've gone like 4 htdocs deep (/htdocs/htdocs/htdocs/htdocs) and there were still the same identical files and folders . . . including a .htaccess file in each of those. Now I don't think that they actually *put* a .htaccess in each file all the way down, so it must be replicating somehow? I really don't know what's going on.

    not2easy

    8:47 pm on Feb 2, 2015 (gmt 0)

    WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



    I would be talking to the host about this time. There is a point when the cost of good hosting becomes a secondary consideration.

    lucy24

    9:32 pm on Feb 2, 2015 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



    when I click on the "htdocs" folder, there's another set of folders identical to the folders above it

    That sounds like a quirk of aliasing. I get a similar going-around-in-circles effect sometimes when I'm checking logs. It shouldn't have any effect on anything.

    phranque

    4:03 am on Feb 3, 2015 (gmt 0)

    WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



    Ooo, good catch on the www vs non www versions . . . I'll have to look.

    i would first verify that example.com and www.example.com are both using the same document root directory.

    I've gone like 4 htdocs deep (/htdocs/htdocs/htdocs/htdocs) and there were still the same identical files and folders

    can you go more than 4 deep?
    perhaps htdocs is a self referential soft link and you are seeing the recursion effect.