Forum Moderators: phranque
Now instead of /products.php?products_id=53, my site now converts that into /myproduct-p-53.html
The problem I've got is that I need to redirect calls to the old style page to the new style. The contribution I installed has a predefined script, but it is not working...
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
Does anyone have any words of wisdom on why it isn't working or have ideas on what to try?
My .htaccess file is in the root of the domain. All the files referenced below are also in the root of the domain.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-(.*).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-(.*).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-(.*).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-i-(.*).html$ information.php?info_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
</IfModule>
[edited by: jdMorgan at 3:08 am (utc) on April 16, 2006]
[edit reason] Example.com [/edit]
How about testing one simple rule, and building up from there, rather than trying to get a big pile of rules to work all at once?
RewriteRule ^myproduct-p-([0-9]+)\.html$ /products.php?products_id=$1 [L]
Jim
The rules I have above are published rules that were developed to accompany the seo friendly url contribution I installed. I haven't heard any complaining about it not working and it is a very popular contribution.
Can you help me disect what the rules are doing?
My understanding is that with the folllowing rule:
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
the ^(.*)-p-(.*).html$ traps all pages that contain -p- and .html at the end and redirects the visitor to /product_info.php?products_id=(number passed in second field of the first part)&(whatever other variables are attached.
Is my interpretation correct? If so, it seems that if I put [mysite.com...]
It should rewrite the URL as [mysite.com...]
Is that correct?