Page 1 of 1

.htaccess and forward slashes

Posted: Thu Jul 27, 2006 3:59 am
by phpdevuk
hello, I'm trying to make human readable urls, using the titles of products as link names with mod rewrite. One of my products has a forward slash in its name, trips everything over nicely. I've tried various methods of getting it working, and annoyingly my regex works in regex workbench just not with mod rewrite! ok see below,

.htaccess

Code: Select all

RewriteEngine On
RewriteRule ^productDetails/-/(.*)/-/(.*)/-/$ productDetails.php?category=$1&product=$2 [L]
my urls look like
http://webserver/website/web/productDet ... ct-name/-/

I'm stumped, think I'm just gonna ban forward slashes!

Posted: Thu Jul 27, 2006 1:16 pm
by bokehman
Maybe like this... what was the problem anyway?

Code: Select all

RewriteRule productDetails/-/((?:(?!/-/).)+)/-/((?:(?!/-/).)+)/-/$ productDetails.php?category=$1&product=$2
I'm not sure how legal lookaround in Apache is though.

Posted: Thu Jul 27, 2006 3:43 pm
by bokehman
Ok I think I have found the problem. Your server is running mod_negociate and that is converting productDetails/ into productDetails.php/ before your rewrite rule is run. The following worked fine on my server (Apache 2.0.54)

Code: Select all

RewriteEngine On
RewriteRule productDetails(?:\.php)?/-/((?:(?!/-/).)+)/-/((?:(?!/-/).)+)/-/$ productDetails.php?category=$1&product=$2 [L]

Posted: Thu Jul 27, 2006 3:47 pm
by phpdevuk
cool, thanks I will give it a try tomorrow