Changing the way of rewrite URL format but google ?

Discuss practical ways rearrange URLs using mod_rewrite.

Changing the way of rewrite URL format but google ?

Postby snowbird » Sat Jun 28, 2008 7:05 am

I want to change view of rewrite URL format but make sure google page links will go to new URL format. Because new google crawling will be in a few days for new format. So can I still have old type URL to be redirected to new ones?

This is my current rewrite URL for product info display
Code: Select all
product-name-p-3761.html


New format:
Code: Select all
product-name,pid3761


Visitors coming from google will click on www.mysite.com/product-name-p-3761.html but www.mysite.com/product-name,pid3761 will be displayed.

OLD FORMAT:
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}

NEW FORMAT:

RewriteRule ^(.*),pid(.*) product_info.php?products_id=$2&%{QUERY_STRING}

Any help?
snowbird
 
Posts: 2
Joined: Sat Jun 28, 2008 6:57 am

Postby richardk » Sat Jun 28, 2008 4:55 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Redirect /product-name-p-3761.html to /product-name,pid3761
RewriteRule ^(.+)-p-([0-9]+)\.html$ /$1,pid$2 [R=301,L]

RewriteRule ^(.+),pid([0-9]+)$ /product_info.php?products_id=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby snowbird » Sun Jun 29, 2008 4:23 am

Richard
You're the legend. That worked very well.

Thank you for your help.
snowbird
 
Posts: 2
Joined: Sat Jun 28, 2008 6:57 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 30 guests

cron