homepage Welcome to WebmasterWorld Guest from 23.23.8.131
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

    
Dynamic URL rewrite
dpinion

5+ Year Member



 
Msg#: 4015536 posted 12:46 pm on Oct 29, 2009 (gmt 0)

Ok, I have been over the mod_rewrite doc and forums and groups for two days trying to figure this out, and haven't gotten it to work yet. I hope someone here can help me.

I have the following URL in google that has been cached:

http://www.example.com/index.php/rackmount-computers/2u-computers?view=subcategory&layout=systems&subcategory_id=19

I need it to be redirected to:

http://www.example.com/index.php/rackmount-computers/2u-rackmount-computers

I have tried various methods with query string and here is the latest iteration:

RewriteCond %{QUERY_STRING} ^view=subcategory&layout=systems&subcategory_id=19?

RewriteRule ^index\.php http://www.example.com/index.php/rackmount-computers/2u-rackmount-computers$1 [R=301,L]

[edited by: jdMorgan at 3:42 pm (utc) on Oct. 29, 2009]
[edit reason] example.com. Please see TOS. [/edit]

 

dpinion

5+ Year Member



 
Msg#: 4015536 posted 1:30 pm on Oct 29, 2009 (gmt 0)

I got it working, but if anyone sees a problem or a way to write this better it would be apprectiated:

RewriteCond %{QUERY_STRING} ^view=subcategory&layout=systems&subcategory_id=19$
RewriteRule ^index.php/rackmount-computers/2u-computers$ http://www.example.com/index.php/rackmount-computers/2u-rackmount-computers? [L,R=301]

[edited by: jdMorgan at 3:41 pm (utc) on Oct. 29, 2009]
[edit reason] example.com. Please see TOS. [/edit]

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4015536 posted 3:44 pm on Oct 29, 2009 (gmt 0)

That solution looks fine, as long as the query string is always in that same exact format, and as long as you have verified that the link to the unwanted URL is *not* on your own site. If it is, you need to fix that link to avoid annoying the search engines.

Jim

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