Mod_rewrite - Can't remove query string

I’m setting up some “work in progress” page redirects. One for the whole site “wip-site” and another for just a page “wip-page”.
I want to set it up so people can’t go on the wip pages when they are not supposed to, or they are not being used.
This is done with a query string, if it’s present they see the page, if not they are sent to the homepage. But I don’t want them to see the query string, so I have a redirect to remove it, only that is not working.
Here are two rules:-

RewriteCond %{QUERY_STRING} !iswip
RewriteRule ^wip-(site|page) http://www.example.com/? [NC,L]

RewriteCond %{QUERY_STRING} ^iswip$
RewriteRule ^wip-(site|page)$ /wip-$1/? [R=301,NC,L]

The first one sends you to the homepage if the query iswip is not present, so: http://www.example.com/wip-page will send you to the homepage: http://www.example.com That works.

In the second rule, if the query iswip is present, as in http://www.example.com/wip-site/?iswip then you get sent to the page, but without the query.
But that’s not working, the query remains.
I thought the ? on the end should remove it.
Anyone know what’s wrong?

SA7,

Is (site|page) a directory? If they are not, then ditch the trailing / as that is what is causing problems.

Using the null query string (? after the SCRIPT name) will eliminate any prior query string.

Regards,

DK

Oh, I totally forgot about this thread. :slight_smile:
I’ll give that a try, thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.