Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. Share your own thoughts and experience, accounts may be terminated for violations.
  • Welcome to AcornDomains.co.uk, a friendly community for UK domain investors, developers and anyone interested in domain names.

    Whether you're looking to buy or sell domains, learn more about the UK domain market, get feedback on your names, or simply chat with other domainers, you're in the right place. AcornDomains has been bringing together people from across the UK domain industry for many years, from complete beginners to experienced investors.

    Have a look around, join the discussions and, if you haven't already, create a free account and introduce yourself.

Any .htaccess wizards out there ?

Status
Not open for further replies.
Joined
May 22, 2007
Posts
43
Reaction score
2
Does anyone know how to write the htaccess rule so that urls containing parameters can be redirected to the root url ?

In other words I want to redirect:

index.php?blah=fred&bob=joe

to:

index.php only ?

This is to stop Google indexing multiple versions of the same page (loooong story !)

Cheers

Phil
 
I haven't tested this, but something like the following should do the trick:

RewriteRule ^index\.php\?.+$ index.php [R=301]
 
I haven't tested this, but something like the following should do the trick:

RewriteRule ^index\.php\?.+$ index.php [R=301]

Nope, it didn't work I'm afraid. The test url index.php?blah=fred remains in the address bar. That's as far as I managed to get myself.

Any ideas ?

Phil
 
If there's a question mark involved you have to use a rewrite condition (RewriteCond) as it's classed as a query string

http://stackoverflow.com/questions/1244881/rewrite-query-string

Thanks Nick, can't quite get my head around that but I think that it's close to what I want. Maybe after some food I'll figure it out !

@Ashton: thanks for the tip. Not sure that it's applicable in this instance but I'll definately use that to ensure that inbound links to different versions of the domain are treated correctly.
 
Status
Not open for further replies.
Top Bottom