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. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

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.

Rule #1: Be Respectful

Do not insult any other member. Be polite and do business. Thank you!

Premium Members

New Threads

Domain Forum Friends

Lastest Listings

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Siusaidh AcornBot:
    Siusaidh has left the room.
      Siusaidh AcornBot: Siusaidh has left the room.
      Top Bottom