htaccess的:重写URL [英] htaccess : rewrite urls

查看:134
本文介绍了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

我认为这将需要的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

这篇关于htaccess的:重写URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆