So i want to rewrite the following url structure




I have this as a rule and it works, but it doesn't force the url to print in the browser when you still point to the old url. So I have duplicate content. I've tried adding [R=302] to it and it doesn't work. [R=302] makes it print the original old url structure (/cgi-bin/shop/shop.cgi/%). Any ideas?

    RewriteRule ^\+([^*]+)/?$ /cgi-bin/shop/shop.cgi/$1

Any help would be greatly appreciated!


You've got the rewrite rule twisted around.

RewriteRule ^\+([^*]+)/?$ /cgi-bin/shop/shop.cgi/$1

means that when the client browses to the page mysite.com/+, your server will act as though they had written mysite.com/cgi-bin/shop/shop.cgi/ instead.

If you want a rewrite to work in the opposite direction, you would need to swap the expression and the target around, like so:

RewriteRule /cgi-bin/shop/shop.cgi/(.*) /\+$1 [L,R]

This means that if the client browses to mysite.com/cgi-bin/shop/shop.cgi/FOO, they will get a redirect to mysite.com/+FOO

Please note that it is not a good idea to use both the current rule and this one at the same time, since you risk causing an infinite loop, at least if you're using redirection, since the redirect will cause a new request that will again be parsed by the redirect rules.

  • Hmmm, that's not working. I tested on it's own and it's not doing anything. Any ideas? – user156466 Jan 29 '13 at 19:18
  • Turn on logging for rewrites. How to do that depends on which version of apache you're running, see docs.apache.com for information. – Jenny D Jan 30 '13 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.