开发者

how to rewrite htaccess

开发者 https://www.devze.com 2023-03-10 04:45 出处:网络
How rewrite using htacess. I have table \"category\" and the values bellow. idnamestatus 1phpA 2javaA 3rubyA

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消