Jump to content

[SOLVED] Product ID Question


linstefoo

Recommended Posts

If you go to my clients website: http://www.everythingdunes.com and hover over a product link, you get the normal "products.html?pid=##". What I would like to do is make that turn into something like this: "product-##.html" and have it bring up that product's information, while still referencing products.html as it's template. An example of what i'm talking about is at:

 

http://epenguins.mobilepenguins.com/product.html ( the template without the product info )

http://epenguins.mobilepenguins.com/product-15.html ( what i'm trying to do )

 

Link to comment
https://forums.phpfreaks.com/topic/70533-solved-product-id-question/
Share on other sites

Tried all of these and thanks for the help, but it just doesn't seem to be working :(

EXAMPLE:

http://everythingdunes.com/product-1.html

 

Here is exactly what I use in my .htaccess file:

RewriteEngine On

RewriteRule ^([^/?]*).html$ /index.php?%{QUERY_STRING}&page=$1 [PT,L]

RewriteRule ^product-([0-9.]+).html$ /index.php?page=products?pid=$1 [L]

 

Am I doing something wrong?

 

try this:

RewriteEngine On
RewriteRule ^([^/?]*).html$               /index.php?%{QUERY_STRING}&page=$1               [PT]
RewriteRule ^product-([0-9.]+).html$       /index.php?page=products?pid=$1 [L]

I removed the first L, because it means last and stops anymore rewrites from happenning. Not sure what PT means though..

I found that it is conflicting with the original mod-rewrite. I realized that I can rewrite it to look like so, it works:

RewriteRule ^product-([0-9]+).htm$      /index.php?%{QUERY_STRING}&page=products&pid=$1  [L]

 

Thanks to all of those who helped and thank you Dragen for suggesting the mod-rewrite conflict.

 

something that you could do which may work (and enable the first re-write to work as well) is simply switch the order they're in so:

RewriteEngine On
RewriteRule ^product-([0-9.]+).html$       /index.php?page=products?pid=$1
RewriteRule ^([^/?]*).html$               /index.php?%{QUERY_STRING}&page=$1 [PT,L]

Otherwise I think you'll find your page link ending in .html will not work.

 

 

EDIT: actually nevermind that. What you've got should work because of %{QUERY_STRING} I think..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.