Forum Moderators: phranque

Message Too Old, No Replies

htaccess gives a page 500 error

         

hostquota

6:12 pm on Feb 14, 2020 (gmt 0)

5+ Year Member



I'm using an old perl email script which works fine but one template for it uses htaccess.
The links on that template are written as xemail?Inbox where the actual file location might be /cgi-bin/inbox.htm, in other words there is no xemail folder.

The script is rather old so maybe there have been changed in how htaccess files are written?
This is the file contents:
RewriteEngine On
Allow all
RewriteRule ^xemail$ /cgi-bin/mail/jilmail.cgi [L]
RewriteRule ^domail$ /cgi-bin/mail [L]

Any ideas?

lammert

6:34 pm on Feb 14, 2020 (gmt 0)

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



Welcome to WebmasterWorld hostquota!

Do you have access to the server log files? When throwing a 500 server error, Apache normally logs details in an error log file with the reason for the error.

hostquota

7:35 pm on Feb 14, 2020 (gmt 0)

5+ Year Member



Thanks a lot for your reply, this is the 4th forum I've asked the same question on in 3 days and the only one to respond! Yes I checked the logs and it wanted allow from all rather than allow all!
Now I know! Thanks again.

lucy24

7:41 pm on Feb 14, 2020 (gmt 0)

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



Edit: Well, oops. I didn't even notice the missing "from". Yup, that will do it!

RewriteEngine On
Allow all
These two lines have nothing to do with each other. Yes, if you’re using mod_rewrite you have to include the line "RewriteEngine on" somewhere in htaccess (by human logic, before all RewriteRules, but the server doesn't care).

"Allow all" is a mod_auth-thingy directive that should be preceded by an "Order" directive. (Default otherwise is "Deny,Allow". If you have no "Deny" directives, order makes no difference.) But that's for Apache 2.2, or 2.4 using mod_compat. If your server is on 2.4--which I certainly hope it is--look into the new "Require" syntax.

I can't conceive of any way the RewriteRules in and of themselves could result in a 500 error. But, just for ### and giggles, see what happens if you change
RewriteEngine On
to
RewriteEngine on
This should make no difference whatsover--directives, unlike arguments, are supposed to be case-insensitive--but it is not long since I used the utterance "Require IP" instead of "Require ip" and it threw a 500 error. Go figure.

hostquota

2:50 am on Feb 15, 2020 (gmt 0)

5+ Year Member



On or on make no difference in my case. Any idea where i can find a good apache or htaccess tutorial?

not2easy

3:46 am on Feb 15, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I have an older perl script in a virtual directory in /cgi-bin and it uses a similar but different format because the virtual directory name is within parentheses.

This part:
RewriteRule ^xemail$
would be
RewriteRule ^(xemail)$
for my rules to work.

One other thing is to add that after your domain canonical rewrite if you use one. Normally rewrite rules would be before the www/non-www and https rewrites, but for the virtual rewrite it is supposed to come after those rules.

re: htaccess tutorial - in your spare time you could browse old threads here and pick up a lot of information and understanding. That "Forum Options" button near the top will lead you to our Apache Library via drop-down menu, but much of that information is rather dated. Apache version matters and in some cases the host has configured things 'differently' so it isn't a 'one size always fits' kind of topic.

lucy24

4:42 am on Feb 15, 2020 (gmt 0)

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



because the virtual directory name is within parentheses
Do you mean that the directory name, as referenced in URLs or in site-internal processes, is the literal string
(xemail)
? If so, the RewriteRule would have to be
\(xemail\)
Otherwise the parentheses would mean you're capturing the exact name "xemail", which isn't needed here since the target doesn't involve a $1 back-reference.

Dimitri

12:19 pm on Feb 15, 2020 (gmt 0)

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



<offtopic>
/cgi-bin/
*love*
</offtopic>

w3dk

2:07 pm on Feb 15, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month




The script is rather old so maybe there have been changed in how htaccess files are written?

Allow all



Was the "Allow all" a recent addition? Or is this how it has always been written? AFAIK the missing "from" has always been mandatory (it would have certainly broken Apache 2.2).

If this is how it has always been written, then it would seem this has never been run before (this template has never been used)?

hostquota

2:24 pm on Feb 15, 2020 (gmt 0)

5+ Year Member



Thanks for all this useful information. Lucy24 there is no directory or file named xemail, un fact the only place it's used is in the links.
So directory structure is something like public_html/cgi-bin/messenger.cgi
But links are written as /cgi-bin/mail/xemail?Messenger

I added the 'from all' the the htaccess and it no longer gives a p500 error but I haven't yet tried the template so wull check that as soon as I get a chance.
Not2Easy thanks for that info on adding that after the canoninical rewrite and for your advice given re tutorials.

hostquota

2:35 pm on Feb 15, 2020 (gmt 0)

5+ Year Member



W3DK that's interesting and I've often wondered if that htaccess has ever worked. The situation is that up until 2008 there was a commercial company known as worldwide scripts who sold a webmail script similar to yahoo or gmail, but one of their team stole the script and rebranded it as jilmail. A war ensued between both rivals until WWS decided to open source it and give it away free, then both became opem source.
Jilmail has a better looking template but I have to go through loads of files to remove the xemail? in order for it to work. Oddly there was another commercial windows product known as xemail and I'm wondering if the jilmail guy stole that template as well?

lucy24

7:10 pm on Feb 15, 2020 (gmt 0)

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



there is no directory or file named xemail, in fact the only place it's used is in the links
That’s perfectly fine. When mod_rewrite gets to work on a request, it doesn’t know and doesn’t care whether the URL in question actually exists or not (unless you throw in a server-intensive RewriteCond using -d or -f). It works on requests, not on physical files. So if a link leads to a request for "xemail", that's what mod_rewrite uses as its pattern.

hostquota

9:13 pm on Feb 15, 2020 (gmt 0)

5+ Year Member



Thanks for clarifying that for me.