homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Problem with using only hyphens in rule

 10:04 am on Aug 9, 2007 (gmt 0)

I have a rule a bit like this

RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)-([a-zA-Z0-9_\-]+)/index.php?$ index.php?sec=$1&cat=$2&cat1=$3&cat2=$4&cat=$2

I have basically got a problem with the last part


This rule cannot use 3 variables in the last part separated by a hyphen.

It works if I use a underscore to separate the last part, however I would rather avoid using underscores or anything other than a slash.

Is it normal to have problems doing this type of thing with rewrite rules?



 4:17 pm on Aug 9, 2007 (gmt 0)

One piece of advise I can offer is that A-Za-z can be simplified to a-z and an [NC] tag added to the end to cater for aNyCase.

I hear that it also works faster with that.


 5:26 pm on Aug 9, 2007 (gmt 0)

Use the [NC] flag:

Now take the hyphens out of the two final groups:

See if that works any better.

The final "?" in your pattern makes the last "p" on ".php" optional. That is, the pattern will match "...index.php" or "...index.ph". Is that really what you wanted?



 8:45 am on Aug 14, 2007 (gmt 0)

Just wanted to say this worked perfectly.

Thanks again JD Morgan :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved