Hi Can someone please help me out with the code below? Where is the problem? Thank you in advance! RewriteEngine On RewriteRule ^(.*)$ index.php?product=$1 [NC,L] Code (markup):
Is that the entire .htaccess file? looks like it should take the Entire url and make it a product. Can you reduce this to RewriteEngine On RewriteRule ^/producs/(.*)$ index.php?product=$1 [NC,L] [code] and wahtever is after /producs/123-Allthistextwillbether will be index.php?product=123-Allthistextwillbether as now your getting a lot more, try to echo the $_GET[product] to see what your getting,. Code (markup):
Yeah, this works. But I don't want anything before the product's name. So I want ^(.*)$, not ^/producs/(.*)$. How can I make it happen? This is everything in my htaccess
well if you have a fake directory or real for products what i put would only give you whats after products.. so unles every page other than the homepage is a product you would need to do somthing like that or parse the difference at pruduct.php post a few example urls here so we can see what you want to do exactly.
Thank you for your time! I am trying to do something similar to wordpress url rewrite. So all url's such as domain.com/category/name-of-category/ would go to index.php?category=name-of-category . While everything else would go to index.php?product=$1 . I was looking for a site that would explain wordpress redirects in details but I couldn't find it anywhere. Could you maybe give me a resource and I'll try to figure it out on my own. Thank you once again for trying to help me
there are a ton of turorials out there. You need to look at both sides, if you have RewriteRule ^(.*)$ index.php?product=$1 [NC,L] Everything after domain.com/ would go to products even /categoey/categoryname/widget will end up as index.php?product=categoey/categoryname/widget and your not going to want that I dont think unless products parses the parts or you use this at the end as a final catch all rule. RewriteRule ^/category/(.*)$ index.php?product=$1 [NC,L] would at least take everything after domain.com/category/ and use it or even better would be RewriteRule ^/category/(.*)$/(.*)$/ index.php?category=$1&product=$2 [NC,L] taking domain.coim/$1/$2
How does wordpress solve that problem? is there a detailed tutorial on how to duplicate wordpress rewrite rules?
Is it possible to do something like if ^/category/(.*)$ index.php?category=$1 [NC,L] else ^(.*)$ index.php?product=$1 [NC,L] ?
well, you could do many things You can use the final swithc after category, ie if this matches then stop procesing rules. I dont use wordpress but I supose they take every request to the index and process the url string from there.
Cool, thanks. I'll do that. But back to the original problem. ^(.*)$ index.php?product=$1 [NC,L] doesn't work for me I do that and then echo product variable in index file but what it actually echo is "index.php" instead of what I type after domain.com. Any idea what could be wrong? Thanks!