Page 1 of 1

Probs with mod_rewrite regex in htaccess file

Posted: Tue May 13, 2008 4:19 am
by lettie_dude
Hi

Just starting out with mod_rewrite and have couple of books and looked at various tutorials on the web. Seems pretty straight forward. I do have an issue though which may or may not be due to my wonderful shared hosting!

As some rules seem to work and some don't and they have already misinformed me on 2 occasions I thought I'd run the rewrite rule by you guys to see if it is indeed something I am doing wrong as opposed to their setup. So rule is:

Code: Select all

RewriteEngine On
 
# Rewrite URLs
RewriteRule ^myurl-to-display/([a-z0-9]+)-range\.html$ /actual_url.php?var=$1 [NC, L]
I am trying to match any number of letters or numbers so the entered url could be something like:

http:www.domain.com/myurl-to-display/ABC1234-range.html

At present this rule crashes the site and the error log states RewriteRule: bad flag delimiters

Can any one confirm if this is correct or not.

Many Thanks

Re: Probs with mod_rewrite regex in htaccess file

Posted: Tue May 13, 2008 4:32 am
by rvijay_eee
You have given a space in square bracket, I have removed it and added th rewritebase in the code.
you also added a slash before actual_url.php. I have removed it

Code: Select all

RewriteEngine On
 RewriteBase /myurl-to-display
# Rewrite URLs
RewriteRule ^([a-z0-9]+)-range\.html$ actual_url.php?var=$1 [NC,L]
http:www.domain.com/myurl-to-display/ABC1234-range.html

Re: Probs with mod_rewrite regex in htaccess file

Posted: Wed May 14, 2008 5:13 am
by lettie_dude
Cheers rvijay_eee

Book I was reading from has a space entered obviously a misprint as it is working fine now!