Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

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.
 
How about something like this?

RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^index\.php$ /index.php? [R=301]
 
Status
Not open for further replies.

The Rule #1

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

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom