Mg Thar
Mg Thar

Reputation: 1102

RewriteRule not working strangly

Rules are actually simple.

RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^path2/myoldurl\.php$ /mynewurl? [R=301,NE,NC,L]
RewriteRule ^path2/myoldur\.php$ /mynewurl? [R=301,NE,NC,L]

The first rules has been there for ages and it is working. But when I tried to add the second one which removed one letter from the first one, is not working at all. When I change the RewriteRule with Redirect or RedirectMatch, it is working.

Bu I cannot use RedirectMatch and Redirect because I have to clear out query string also.

Is there any idea why it is not working? I already restarted the apache also. Can it be these RewriteRule cache in some where?

EDIT

I just realized that the old rules is still working even after I removed both rules. But I'm sure .htaccess is working since it redirect the new url when I add Redirect 301 or RedirectMatch in this file. Please help!!!!

EDIT 2

One more thing I realized is that, once I added a new Redirect script it is working. And it is still working EVEN AFTER I REMOVED IT BACK :(

Upvotes: 0

Views: 109

Answers (1)

Panama Jack
Panama Jack

Reputation: 24478

You can simply make that letter l optional. So it will match either one of them and you have one rewriterule.

RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^path2/myoldurl?\.php$ /mynewurl? [R=301,NE,NC,L]

Clear your browser cache before trying new rules.

Upvotes: 1

Related Questions