Jump to content

Rewrite not working on my server.


AbydosGater

Recommended Posts

Hi,

Mod_rewrite is active on my hosts server.

But i get a 500 internal server error when the .htaccess is in place.

 

I contacted my support and they said it was an error with the RegEx in the file.

But it works for me on my local dev server.. and works fine on a friends server.

 

RewriteEngine On
RewriteRule ^([A-Za-z0-9]+)/?$ index.php?module=$1
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9-/]+)/?$ index.php?module=$1&params=$2

 

To me the regex looks fine to me.

 

The only thing i can think of is that my host is apache 1.3.9

and the others are apache 2.

 

Do you have any idea on how i could fix this to work?

 

Any help greatly appriciated.

Andy

Link to comment
Share on other sites

Wouldn't even hazard a guess without examining the access and rewrite logs. No idea how your support could be so confident with minimal info. If they had enough info to be certain (e.g. rewrite expertise) they ought to have been able to point out where.

 

Add (level 5 or 9 as appropriate)

RewriteEngine On
RewriteLogLevel 9
RewriteLog logs/rewrite.log

 

Then use tail -f to watch the rewrite log in real time whilst sending a relevant "hit" to the server to detect the *actual* file involved.

Check the file is actually producing content rather than issuing null output (which could generate 500 server errors)

 

Also, you should be able to selectively pinpoint by "commenting-out" all rules and then re-including one at a time till you find the *actual* rule which loads the offending page.

 

Just a suggestion ;)

 

EDIT Amend rewrite log filename as appropriate for Linux/Novell whatever

Link to comment
Share on other sites

Hi MadMax,

Thank you very much for your reply.

 

I tried adding the log data to the .htaccess and it only gave me an error about access rights.

Not to worry though.

 

In the error logs, It says

: cannot compile regular expression '^([A-Za-z0-9]+)/([A-Za-z0-9-/]+)/?$'\n

 

Now after removing them one at a time i found that it is an issue with the second rewrite rule

RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9-/]+)/?$ index.php?module=$1&params=$2

 

Can you see what would be wrong with that regular expression?

Link to comment
Share on other sites

Ok i have noticed.

It is the "-/" in the second variable of the regular expression.

 

([A-Za-z0-9-/]+)

 

See after the 9 .. -/ so that the variable may include forward slashes too.

 

With that in there it is causing the error.

But my module system is designed around parameters being sent and split by /'s

 

Is there any other way to include /'s to be allowed?

 

Andy

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.