Martin
Martin

Reputation: 22760

bad flag delimiters on mod_rewrite

I have an htaccess mod_rewrite which should:

take site.co.uk/text and turn it into site.co.uk/text BUT working as: site.co.uk/biz.php?name=text , with the qualifiers it only effects strings after the / that are not a file or folder. My code is here:

RewriteCond %{REQUEST_FILENAME} !-d # not an existing dir
RewriteCond %{REQUEST_FILENAME} !-f # not an existing file
RewriteRule ^([\w]+)$ cottages.php?name=$1 [P,NC,QSA] 

I get the error 500:

public_html/.htaccess: RewriteCond: bad flag delimiters

Which seems to me to be either the flags [P,NC,QSA] OR the regex query?

I have rewritten the regex as [a-zA-Z0-9] but this has not changed the error. I have also removed individual and all flags but this has also not changed the error. commenting out the lines does remove the error. I think the error is in the RewriteRule but I also need to remove the conditions if removing (commenting out) the rule.

Can you see what I'm doing wrong?

Cheers

P.s> I Hate htaccess Mod rewrite, it's a pain in the diddles!!

Upvotes: 1

Views: 644

Answers (1)

anubhava
anubhava

Reputation: 785256

Have it this way:

# not an existing dir
RewriteCond %{REQUEST_FILENAME} !-d
# not an existing file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(\w+)/?$ cottages.php?name=$1 [P,QSA]

Comments cannot follow RewriteCond on same line.

Upvotes: 1

Related Questions