Welcome to WebmasterWorld Guest from 54.196.175.173

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Dynamic URL rewrite

     

dpinion

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

5+ Year Member



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

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

5+ Year Member



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

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

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



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month