I'm trying to optimize my site to make it SEO and user-friendly, I have several problems to set the right mod_rewrite for the urls and need help for this, I'm new to it, so it's way beyong my knowledge for the moment. http://bit.ly/2Ocf3B , the site should look like this: www.domain.me/category/subcategory . thanks
views:
49answers:
1
A:
You have a file that accepts two HTTP GET parameters, category
and subcategory
. Let's say http://www.example.org/products.php?category=bicycles&subcategory=racing
yields an index of racing bikes.
To transform that URL into something prettier, say http://www.example.org/bikes/racing
, enter this into your .htaccess file:
RewriteEngine On
RewriteRule ^products/([a-zA-Z]*)/([a-zA-Z]*)$ products.php?category=$1&subcategory=$2
As you can see, mod_rewrite revolves around regular expressions. If you don't know your way around them, I recommend you look into regular-expressions.info to get started. When you've learned the basics, it can be very educational to play around in a regex tester (I like RegexPal, but there are hundreds of alternatives).
Johannes Gorset
2010-02-28 15:48:50
Thanks FRKT, I'll try to gain more knowledge about the .htaccess, i just tought, someone could help me write a piece of code snipet that can make my urls look prttier. the problem with this is just that, my site has several urls, so i can't apply the conventional mod_rewrite here, i guess i need some additional code for my index file, i just need to figuer out how to do this.
2010-03-01 16:08:40
@user257357: I think you'll just have to learn it. You'll thank me later. ;-)
Johannes Gorset
2010-03-01 16:57:19