Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Case Insensitive Rewrite Rule

I know I need to add an "i" but where?



8:16 pm on Dec 28, 2007 (gmt 0)

5+ Year Member

I'm trying to modify a rewrite rule in my .htaccess file to be case insensitive.

RewriteRule ^([aeiouy]{1})/?$ ...

I know I need to add an "i" somwhere to make it to also accept uppercase letters, but where?

I guessed inside the set at the end, but it didn't seem to work.
RewriteRule ^([aeiouy/i]{1})/?$ ...


9:18 pm on Dec 28, 2007 (gmt 0)

5+ Year Member

You need to set flag (NC) as third argument to the RewriteRule directive.

Apache module mod_rewrite [httpd.apache.org]



9:30 pm on Dec 28, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

And the "{1}" is redundant, since {1} is the default quantifier for all pattern elements:

RewriteRule ^([aeiouy])/?$ new_path [NC]

Also, you won't need the parentheses unless you wish to back-reference the enclosed matched subpattern.



9:42 pm on Dec 28, 2007 (gmt 0)

5+ Year Member

Thank you.

The [NC] does the trick, and I also didn't realize that {1} is redundent, now now I'm able to trim up my code a bit.

I do back reference the subpattern.


Featured Threads

Hot Threads This Week

Hot Threads This Month