Not sure the correct forum to post this in - apologies if it is in the wrong area.

I have just finished a drupal site rebuild. The original was a non-drupal site and some of the links used URL queries. I have added a number of 301 redirects into the .htaccess file to direct the old pages to the new drupal url's. The problem I'm having is only with old urls that had queries in the url. For the example below, the original page was page.php?cat=01, that I wanted to redirect to http://www.example.com/new/page

from .htaccess (placed above the standard drupal install mod_rewrites)

RewriteCond %{QUERY_STRING} ^cat=01$
RewriteRule ^/page.php$ http://www.example.com/new/page? [L,R=301]

From quite a bit of research into how to achieve this, I though that the method shown above would accomplish this - specifically the '?' on the end of the destination absolute url would remove the query however it is still there. It's not a huge concern as the pages are still redirecting ok (just with the useless query at the end of each path alias). Has anyone else had this problem?

Comments

jevets’s picture

Quick question:

Is "RewriteEngine On" above your rewrite stuff?

paul-daniel’s picture

Hi jevets,

Yes, RewriteEngine On is above the custom redirects. Structure is like this:


RewriteEngine on

#my custom redirects

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

The basic redirects are all working. Just these queries aren't getting removed from the new drupal url aliases..

jevets’s picture

And you've cleared the browser cache?

I agree, looks like it should be working...

paul-daniel’s picture

yes.. all caches cleared. it's not a functional problem in that all the redirects are going to the right pages, it's merely a cosmetic issue since when search engines follow and store those redirects, those ugly (and now useless) queries will be in the url until such time that all search engines have the correct links and i can remove the redirects.

Just thought perhaps there was a simple mistake in my syntax.

Thanks again.

arhak’s picture

if the rule doesn't have the QSA flag it should be removing the query string
I recommend you to search http://httpd.apache.org for any help on forcing the inverse of QSA, but it shouldn't be appending the query string without it