views:

26

answers:

2

Hello. 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?

A: 

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

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

krico
+1  A: 

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]
Artefacto
This is the correct regex but it still doesn't match in .htaccess. grrrr
frio80
Artefacto