Is this too intensive of a pattern?

Discussion in 'Apache' started by algowatch, Feb 11, 2007.

  1. #1
    I am using mod_rewrite to rewrite some URL's for a database application. One of my URL's I am rewriting must start (after the base folder) with a folder named after one of the 50 U.S. states (ie. /alabama/, /alaska/, /arizona/, and so on.).

    Is it okay to include all 50 of these state names within my RegEx pattern conditional? Or is that way too much info to put into a pattern and be too intensive?

    Example:
    ^/?(alabama|alaska|arizona|arkansas|california|colorado|connecticut|delaware|florida|georgia|hawaii|idaho|illinois|indiana|iowa|kansas|kentucky|louisiana|maine|maryland|massachussets|michigan|minnesota|mississippi|missouri|montana|nebraska|nevade|new-hampshire|new-mexico|new-york|north-carolina|north-dakota|ohio|oklahoma|oregon|pennsylvania|rhode-island|south-carolina|south-dakota|tennesee|texas|utah|vermont|virginia|washington|west-virigina|wisconsin|wyoming)/([a-zA-Z_]+)/([a-zA-Z_]+)$
    Code (markup):
     
    algowatch, Feb 11, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It shouldn't be a problem. Obviously it completely depends on your server and the amount of traffic you're getting. If you're worried about performance, put the rewriting code in your httpd.conf rather than .htaccess so that it's compiled as apache starts, rather than interpreted for every request.
     
    rodney88, Feb 11, 2007 IP