LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-21-2010, 01:17 PM   #1
guessity
Member
 
Registered: Dec 2009
Posts: 41

Rep: Reputation: 15
Post Need help with .htaccess


For some reason google is indexing my site with the following for all the urls

Code:
?utm_source=twitterfeed&utm_medium=twitter
like

Code:
http://www.url.com/news/2010/10/people-live.html?utm_source=twitterfeed&utm_medium=twitter
Can anybody help me do a 301 redirect so my final url is

Code:
http://www.url.com/news/2010/10/people-live.html
It should basically remove the odd stuff and redirect for all the urls.

Last edited by guessity; 10-21-2010 at 01:25 PM.
 
Old 10-21-2010, 01:33 PM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,908

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
Hi,

Use the following in a .htaccess
Code:
RewriteEngine on

RewriteCond %{QUERY_STRING} ^utm_source=(.*)
RewriteRule (.*) http://www.url.com/news/2010/10/people_live.html? [R=301,L]
Regards
 
Old 10-21-2010, 01:36 PM   #3
guessity
Member
 
Registered: Dec 2009
Posts: 41

Original Poster
Rep: Reputation: 15
I have over 500 urls with the same problem.

Is it possible to remove them in one shot rather then create 500 ood lines?
 
Old 10-21-2010, 01:41 PM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,908

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
Sure.
Just give more details, like what is the generic form of the URLs you want to rewrire and how they should look after rewritting
 
Old 10-22-2010, 12:59 AM   #5
guessity
Member
 
Registered: Dec 2009
Posts: 41

Original Poster
Rep: Reputation: 15
The problem is all my urls are being indexed by google with the following in the end -

Code:
?utm_source=twitterfeed&utm_medium=twitter
I basically want to 301 redirect to the original link without it at end.
 
Old 10-22-2010, 02:06 AM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,908

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
So you want to remove the QUERY_STRING (everything after the 1st ?)
If that's the case, you can use:
Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} !^$
RewriteRule (.*) /$1? [R=301,L]
Regards
 
1 members found this post helpful.
  


Reply

Tags
htaccess


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help with .htaccess taydu3000 Linux - Server 1 12-04-2007 05:51 PM
.htaccess help sgware General 1 12-10-2006 01:52 PM
.htaccess ralide Linux - Software 3 06-18-2005 11:15 AM
.htaccess Lionheart008 Linux - Newbie 1 10-15-2004 02:15 PM
htaccess xlord Linux - Newbie 1 01-16-2004 09:20 PM


All times are GMT -5. The time now is 08:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration