frio80
frio80

Reputation: 1323

Mod_rewrite condition not working

I've checked the regexs and they all match but for some reason its not working in mod_rewrite?

I would like

http://www.system.com/chips/intel?c=xxx

to read:

http://www.system.com/chips/intel/xxx

I have:

RewriteCond %{REQUEST_URI} (c=.*)$
RewriteRule (/([^/]+)/?).*?c=(.*) http://%{SERVER_NAME}/$1/$2/ [L]

And I'm getting an error. What's going on here?

Upvotes: 0

Views: 132

Answers (2)

Artefacto
Artefacto

Reputation: 97805

Your regular expression doesn't match that URL. As you have it:

  • group 1 matches /chips/
  • group 2 matches chips
  • group 3 matches xxx

You probably want something like:

RewriteRule ^/([^/]+)/([^/]+)\?c=([^&]*)  http://%{SERVER_NAME}/$1/$2/$3 [R=301]

Upvotes: 1

krico
krico

Reputation: 5728

Don't think rewritecond get's the uri params unless you have "QSA"

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Upvotes: 0

Related Questions