mod_rewrite illegal characters

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

mod_rewrite illegal characters

Post by paqman »

I've set up a CMS system using mod_rewrite, but have run into a small problem. If the user enters, for the 'url name' (http://thesite.com/urlname/) certain invalid characters, the .htaccess file is screwed and the whole website stops working (as expected). I'm going to put in a check to make sure the user cannot enter invalid characters, but which characters are illegal in the .htaccess file? The file looks like this:

Code: Select all

 
RewriteRule ^(products|about|testimonials|services|residential|commercial|Auto and Marine Services|tips)/$ /~kcslocks/pages.php?calling=$1
 
where the names in the brackets are automatically written by a php function every time a page is updated. The 'Auto and Marine' causes the problem. So, does anyone have a list of invalid characters? Does it follow the same rules as a URL? Any help is appreciated.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: mod_rewrite illegal characters

Post by Darhazer »

The space should be escaped: "\ "

Code: Select all

RewriteRule ^(products|about|testimonials|services|residential|commercial|Auto\ and\ Marine\ Services|tips)/$ /~kcslocks/pages.php?calling=$1
Post Reply