views:

23

answers:

4

I am trying to get a mod_rewrite working correctly.

Here is the code:

RewriteCond %{QUERY_STRING} ^main_page=product_info&products_id=301$ 
RewriteRule ^index\.php$          
/blog/shop/index.php?route=product/product&product_id=301? [R=301,L]

It works, but in the end of the new URL %3f is added. Can somebody help me to get it work?

+1  A: 

Put no-escape flag NE at the end:

RewriteRule ^index\.php$          
/blog/shop/index.php?route=product/product&product_id=301? [R=301,L,NE]
Petr Kozelek
tried with the NE flag but no change.
proximity
Why do you need that question mark in the URL?
Petr Kozelek
A: 

%3f is the question mark at the end of your statement. Take that out and you should be good.

RewriteCond %{QUERY_STRING} ^main_page=product_info&products_id=301$ 
RewriteRule ^index\.php$          
/blog/shop/index.php?route=product/product&product_id=301 [R=301,L]
bradenkeith
proximity
Is your browser caching the response? That's odd that there's *no* change. Either Petr or my responses should have been your solution...
bradenkeith
A: 

%3f is the "?" you have at the end of your "Target URL" - just URL escaped. Is this really supposed to be there?

BlaM
took it right away, doesn't change anything.
proximity
A: 

The %3f is the ? at the end of your replacement in percent-encoding. Just drop the ? at the end:

RewriteCond %{QUERY_STRING} ^main_page=product_info&products_id=301$ 
RewriteRule ^index\.php$ /blog/shop/index.php?route=product/product&product_id=301 [R=301,L]

You would only use a ? at the end to indicate an empty query so that the requested query does not get appended to the new URL if it does not contain a query.

Gumbo
proximity
Probably the old redirection is cached in your browser.
Petr Kozelek