Jump to content
Larry Ullman's Book Forums

Mod_Rewrite And Redirects For Existing Indexed Links


Recommended Posts

I am modularizing a existing site as discussed in Chapter 2.  All is working fine but I cannot seem to find the correct rewrite script for my .htaccess relative to rewriting (or forwarding existing) links that have been indexed in search engines. An example:

 

http://www.example/productdetail.php?id=100 (as indexed by Google) should display as

 

http://www.example/product-detail/100/

 

but instead is displaying in address bar as

 

http://www.example/product-detail/?id=100 (and obviously no page is found)

 

My current .htaccess is:

 

RewriteEngine On

RewriteRule ^([^/]*)/$ /index.php?p=$1[L]

RewriteRule (product-detail)/([^/]*)/$ /index.php?p=$1$id=$2

 

I also have a URL redirect for this page:

Redirect 301 /productdetail.php http:www.example.com/product-detail/

 

Any assistance would be appreciated.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...