homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

301 Redirect URL w Variables .htaccess

 5:25 pm on Jul 26, 2010 (gmt 0)

I've searched the forums and tried all the examples I could find but for some reason can't get this to work. I have a URL that needs to be 301 redirected because of duplicate content concerns.


...should read...


I have tried a number of solutions, here is the code I have currently. This did something similar on a different domain.

RewriteCond %{QUERY_STRING} ^q=degree-programs(.*)$
RewriteRule ^(.*)$ http://www.example.edu/academics/degree-programs$1? [R=301,L]

The thought behind this is that it should find anywhere the q=degree-programs query string appears and redirect it to the URL in rewrite rule. What's going wrong here?

[edited by: jdMorgan at 8:17 pm (utc) on Jul 26, 2010]
[edit reason] example.edu for readability [/edit]



 6:42 pm on Jul 26, 2010 (gmt 0)

The ^ operator is "begins with" so it cannot match "anywhere".

&?q=degree-programs&? or similar.

The ^ and $ are not required.


 8:33 pm on Jul 26, 2010 (gmt 0)

Also, the code and your example don't match. How much of the URL-path is variable, and how much of it is fixed?

It seems that you are adding a "second copy" of "/academics/degree-programs" into the URL-path with the code that you have posted, unless the code is located in /academics/degree-programs/.htaccess

Is that the case?



 1:16 pm on Jul 27, 2010 (gmt 0)

The .htaccess resides in the root directory. And I took what he said and turned it into...

RewriteCond %{QUERY_STRING} &?q=advanced-certificate-programs$
RewriteRule ^(.*)$ [domain.edu...] [R=301,L]

which works in every case I have currently. The way you mentioned it might be duplicating the page worries me. What did you mean by that?

Thanks guys, your always so much help!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved