linstefoo Posted September 24, 2007 Share Posted September 24, 2007 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 ) Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/ Share on other sites More sharing options...
sstangle73 Posted September 24, 2007 Share Posted September 24, 2007 modrewrite Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354334 Share on other sites More sharing options...
linstefoo Posted September 24, 2007 Author Share Posted September 24, 2007 here the mod write I tried: RewriteRule ^product-([^/?]*).html$ products.php?id=$1 [PT,L] What's wrong with this? I added just a plain old "R" to it and it broke. Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354336 Share on other sites More sharing options...
sstangle73 Posted September 24, 2007 Share Posted September 24, 2007 oo me and mod rewrite dont get along lol youll have to wait for someone else all i know is it will solve your problem Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354337 Share on other sites More sharing options...
marcus Posted September 24, 2007 Share Posted September 24, 2007 Try this: RewriteEngine On RewriteRule ^product-([^-]*).html$ products.php?id=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354338 Share on other sites More sharing options...
sstangle73 Posted September 24, 2007 Share Posted September 24, 2007 ^product-([^/\.]+).html/?$ /products.php?id=$1 [L] you can try but like i said im not good at all with modrewrite haha Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354339 Share on other sites More sharing options...
Dragen Posted September 24, 2007 Share Posted September 24, 2007 RewriteRule ^product-([0-9]+).html$ products.php?pid=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354340 Share on other sites More sharing options...
linstefoo Posted September 24, 2007 Author Share Posted September 24, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354343 Share on other sites More sharing options...
Dragen Posted September 24, 2007 Share Posted September 24, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354346 Share on other sites More sharing options...
linstefoo Posted September 24, 2007 Author Share Posted September 24, 2007 PT stands for Pass Through. I discovered that if I delete the .html$ and just go like that, it comes up. http://everythingdunes.com/product-1 This is quite interesting. Any ideas on why it's acting funny? Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354354 Share on other sites More sharing options...
marcus Posted September 24, 2007 Share Posted September 24, 2007 Try this: RewriteRule ^product\-([^-]*)\.html index.php?page=products&pid=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354359 Share on other sites More sharing options...
Dragen Posted September 24, 2007 Share Posted September 24, 2007 not always. Try putting id as 2 and it doesn't work. It could be that it's having conflict with the first re-write. Try removing the first re-write and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354361 Share on other sites More sharing options...
marcus Posted September 24, 2007 Share Posted September 24, 2007 RewriteEngine On RewriteRule ^products-([^-]*)\.html$ /index.php?page=products&pid=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354367 Share on other sites More sharing options...
linstefoo Posted September 24, 2007 Author Share Posted September 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354373 Share on other sites More sharing options...
Dragen Posted September 24, 2007 Share Posted September 24, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354376 Share on other sites More sharing options...
linstefoo Posted September 24, 2007 Author Share Posted September 24, 2007 I just thought you'd like to know that that worked, now my products end in .html. Thanks again for your assistance Quote Link to comment https://forums.phpfreaks.com/topic/70533-solved-product-id-question/#findComment-354388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.