Welcome to WebmasterWorld Guest from 54.160.177.33

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Dynamic URL rewrite

     
12:46 pm on Oct 29, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2008
posts: 73
votes: 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]

1:30 pm on Oct 29, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2008
posts: 73
votes: 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]

3:44 pm on Oct 29, 2009 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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