views:

199

answers:

2

I am trying to rewrite a URL for a Dreamhost served website.

I want to do the following:

Goal:

Rewrite only URLs that start with an x.

This:

http:// domain.com/x23

Should become:

http:// domain.com/index.php/lookup/code/x23

I tried this:

RewriteEngine On
RewriteRule ^(x[0-9a-z])$ index.php/lookup/code/$0 [L]

but it doesn't seem to work.

What am I missing?

+1  A: 

You forgot a quantifier for [0-9a-z]. Your expression does only allow one character of [0-9a-z]. Try the + quantifier for one or more repetitions:

RewriteRule ^x[0-9a-z]+$ index.php/lookup/code/$0 [L]
Gumbo
Awesome thanks for the answer. Somehow to make it work on Dreamhost I also needed to add a question mark after php -> RewriteRule ^(x[0-9a-z]+)$ index.php?/lookup/code/$0 [L]Any ideas why?
mistero
@mschoening: Maybe *AcceptPathInfo* is not on (see http://httpd.apache.org/docs/2.2/mod/core.html#acceptpathinfo).
Gumbo
A: 

I think you want this:

^(x[0-9a-z]+)$   # Note the +, so it matches more than one
Paul Betts