AbydosGater Posted January 27, 2008 Share Posted January 27, 2008 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¶ms=$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 Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/ Share on other sites More sharing options...
madmax Posted January 27, 2008 Share Posted January 27, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/#findComment-450555 Share on other sites More sharing options...
AbydosGater Posted January 28, 2008 Author Share Posted January 28, 2008 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¶ms=$2 Can you see what would be wrong with that regular expression? Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/#findComment-451369 Share on other sites More sharing options...
AbydosGater Posted January 28, 2008 Author Share Posted January 28, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/#findComment-451385 Share on other sites More sharing options...
Dragen Posted January 28, 2008 Share Posted January 28, 2008 can't you try escaping it with a backslash? ([A-Za-z0-9\/]+) I think the above might just include the backslash in available characters though, but something like that. maybe: (\/[A-Za-z0-9])+ Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/#findComment-451395 Share on other sites More sharing options...
AbydosGater Posted January 28, 2008 Author Share Posted January 28, 2008 Whoot thank you !!1!!one That worked Also removing the - from -/ works too.. Found that after you posted. Thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/#findComment-451415 Share on other sites More sharing options...
Dragen Posted January 28, 2008 Share Posted January 28, 2008 glad I could help! seems like you found the quicker fix though Quote Link to comment https://forums.phpfreaks.com/topic/88045-rewrite-not-working-on-my-server/#findComment-451418 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.