I've recently converted an html site that I did a while back into a Drupal install so that others in the company can easily edit things. Everything went well enough, but I am now completely baffled by a .htaccess problem I am having.

I have redirected all the html pages as follows (just a snippet of them all) :

redirect 301 /sports.html http://www.udoschoice.co.uk/udo_oil_and_sports
redirect 301 /winwinwin.html http://www.udoschoice.co.uk/win_win_win
redirect 301 /buy-online.htm http://www.udoschoice.co.uk/shop/index.php
redirect 301 /locator.html http://www.udoschoice.co.uk/udos_oil_store_locator

These all work great. However, on our adverts, and other marketing info, we also direct people to udoschoice.co.uk/sports, and /locator - this is just done for the simplicity of not putting in a big URL. The redirects have been set as follows:

redirect 301 /sports http://www.udoschoice.co.uk/udo_oil_and_sports
redirect 301 /locator http://www.udoschoice.co.uk/udos_oil_store_locator

Now, when udoschoice.co.uk/sports, and udoschoice.co.uk/locator are entered into any browser, they redirect as follows:

http://www.udoschoice.co.uk/udo_oil_and_sports?q=sports
http://www.udoschoice.co.uk/udos_oil_store_locator?q=locator

Where is the ?q= coming from - I'm baffled. It is preventing the pages from loading, and throwing a 404 instead.

I could just change the URL aliases to match the ones that we use in our marketing info, however, I would rather for SEO purposes keep the new names.

Any thoughts?!?

Comments

Anonymous’s picture

It looks like your redirect rule is inferring the QSA (query string append) flag. If you change you code to look like this, which hasn't got QSA specifically appended, you should be ok:

RewriteRule /sports.html http://www.udoschoice.co.uk/udo_oil_and_sports [R=301,L]
tony barnes’s picture

Thanks for the reply, though not quite what I was after - the redirect of /sports.html to udo_oil_and_sports is working fine, it is the redirect of /sport to udo_oil_and_sports that isn't working.

Haven't heard of QSA before though, so will investigate!

(also just realised it should technically be udos_oil_and_sports, so will be amending that typo, just an aside, as irrelevant for teh actual problem)

tony barnes’s picture

Ok, after lots of searching, I've given up on using htaccess to solve this, doesn't seem to work...!

So, figured out the alias system would work - set up the /node/22 to work with sports, and /node/21 to work with locator - works a charm. Site redirects internally, and all is gravy.

Weird thing is, the URL that is displayed is IDENTICAL to the URL that was displayed previously, but now it works... meh, don't really care why, but worth a mention!

Now working example -

www.udoschoice.co.uk/sports

akoepke’s picture

Just make sure you don't end up with two URLs for the one content page as that can degrade the quality of your site in the eyes of Google and other search engines.

Also for simple redirects in Drupal 7, you can use the Redirect module which makes life a lot easier. We have that setup on the site I manage to redirect from most of the old URLs.

We also use Global Redirect to make sure that there is only 1 URL per content item.