htaccess的:重写URL重写、htaccess、URL

由网友(玖)分享简介:请帮忙从http://www.site.com/index.php?cat=catname 和http://www.site.com/index.php?id=productname 是这样http://www.site.com/catname 和http://www.site.com/productname...

请帮忙从

http://www.site.com/index.php?cat=catname

http://www.site.com/index.php?id=productname

是这样

http://www.site.com/catname   和   http://www.site.com/productname

我认为这将需要的PHP检查,如果该网页是猫的工作,它的猫  或与它的产品配合使用产品的

i think it will require php check if the page is cat work with it as cat or its product work with it as product

推荐答案

在.htaccess文件:

in .htaccess file:

RewriteEngine On

RewriteRule ^([0-9a-z-_]+)?$ /index.php?id=$1 [L,QSA,NC]

类/产品的检查必须在index.php中完成...

category/product check must be done in index.php...

或者,你可以添加额外的蛞蝓

Or you can add extra slug

RewriteRule ^(category)/([0-9a-z-_]+)?$ /index.php?category=$1 [L,QSA,NC]
RewriteRule ^(product)/([0-9a-z-_]+)?$ /index.php?product=$1 [L,QSA,NC]

但URL看起来像 http://site.com/category/catname

阅读全文

相关推荐

最新文章