how to rewrite htaccess
How rewrite using htacess.
I have table "category" and the values bellow.
id name status 1 php A 2 java A 3 ruby A 4 perl A
www.sample.com/category.php?id=1 www.sample.com/category.php?id=2 www.sample.com/category.php?id=3 www.sample.com/category.php?id=4
I want to change the above url to:
www.sample.com/php/1 www.sample.com/j开发者_JAVA技巧ava/2 www.sample.com/ruby/3 www.sample.com/perl/4
Help guys my problem
Thanks,
Richard
Something like this, perhaps:
RewriteEngine on
RewriteRule ^category\.php\?id=1$ php/1 [L]
RewriteRule ^category\.php\?id=2$ java/2 [L]
RewriteRule ^category\.php\?id=3$ ruby/3 [L]
RewriteRule ^category\.php\?id=4$ perl/4 [L]
Put this code in your .htaccess file:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteRule ^(php|java|ruby|perl)/([0-9]+)/?$ /category.php?id=$2 [L,NC,QSA]
精彩评论