using mod_rewrite in linux is fine, but craps out on windows

Oh, the strange things mod_rewrite does!

using mod_rewrite in linux is fine, but craps out on windows

Postby shogo2040 » Thu Oct 22, 2009 11:45 pm

For legacy reasons, I have to develop on an old version of XAMPP on Windows XP. My web hosting runs on linux (maybe debian).

My old xampp dev environment runs perfectly with the exception of Mod Rewrite.. for some reason, some mod_rewrite commands that work on .htaccess on my web hosting just craps out for mod_rewrite rules on XAMPP 1.6 on windows... and I really don't want to develop on my live shared hosting account on my web hosting.

This works fine on both my web hosting and XAMPP 1.6:
RewriteRule ^$ /_controller.php?object=recentreviews&method=list

This only works on my web hosting, but craps out on XAMPP 1.6 on windows:
RewriteRule ^([a-z0-9._:\-\(\)\!\/\'\,]+)/([a-z0-9._:\-\(\)\!\/]+)/reviews/([0-9]+)$ /_controller.php?object=reviews&method=list&params=$3,10,0,1,$1,$2

Is there a cross platform issue of Windows slash/backslash VS Linux slash/backslash when it comes to mod rewrite? thats the only thing I can think of. What other syntax can I try to get this working in both windows and linux ?
Thanks for any suggestions.
shogo2040
 
Posts: 8
Joined: Tue May 12, 2009 10:55 pm

Postby richardk » Fri Oct 23, 2009 9:06 am

There are errors about the regular expression in your error log?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([-a-z0-9._:()!/',]+)/([-a-z0-9._:()!/]+)/reviews/([0-9]+)$ /_controller.php?object=reviews&method=list&params=$3,10,0,1,$1,$2 [QSA,L]


Also try
Code: Select all
^(.+)/([^/]+)/reviews/([0-9]+)$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

The 2nd / shorter one worked!

Postby shogo2040 » Sat Oct 24, 2009 8:55 am

Amazing! The 2nd regex you wrote is so short and so powerful and fixed the issue! My favorite part was when you did this:

Code: Select all
([^/]+)


A one or more match on no slashes!!

Thanks again.

I'll tail my log to fix more using those short and sweet type of regex.
shogo2040
 
Posts: 8
Joined: Tue May 12, 2009 10:55 pm


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 7 guests

cron