简体   繁体   English

使用php mysql在htaccess中进行URL重写规则

[英]url rewrite rules in htaccess with php mysql

How write url rewrite rules given below links. 下面的链接如何编写url重写规则。

  1. original url for match pages: 匹配页面的原始网址:

     http://www.cricmelive.tv/live/09876/barisal_bulls_vs_chittagong_vikings_t20 

now needed url: 现在需要的网址:

    http://www.cricmelive.tv/live/09876/barisal_bulls_vs_chittagong_vikings_t20

2. original url for Channel Catgry: 2. Channel Catgry的原始网址:

http://www.cricmelive.tv/live/category.php?id=1 

now needed url as: 现在需要的网址为:

http://www.cricmelive.tv/live/sports

3. original url for Sports Catgry: 3.体育类的原始网址:

http://www.cricmelive.tv/live/index.php?catid=1 

now needed url as : 现在需要的网址为:

http://www.cricmelive.tv/live/cricket

4. orignal url for Channel Pages: 4.频道页面的原始网址:

http://www.cricmelive.tv/live/channel-page.php?cid=45   

now needed as : 现在需要为:

http://www.cricmelive.tv/live/espn-3-live-streaming

I am new in ur rewrite. 我是您重写的新手。 I post it again. 我再次发布。 Help me, how write rewrite url code again original url 帮帮我,如何再次写重写URL代码原始URL

I see what you are trying to do but it doesn't work that way. 我了解您正在尝试执行的操作,但这种方法无法正常工作。 The parameters in the querystring are used at the backend in the sql to find the relevant records in the db using $_GET . querystring中的参数在sql的后端使用,以使用$_GET在数据库中查找相关记录。

catid=45 does not directly translate to cricket - in the database perhaps catid=1 probably is cricket but the webserver doesn't know this relationship so you would need to alter your sql query such that it used cricket as the parameter in the where clause rather than 1. catid=45不会直接转换为cricket在数据库中catid=1可能是cricket但是网络服务器不知道这种关系,因此您需要更改sql查询,以便它在where子句中使用cricket作为参数而不是1。

For example: 例如:

http://www.cricmelive.tv/live/1 

that could be expressed easily with a rewrite rule, such as:
RewriteRule ^live/([0-9]+)$ live/index.php?catid=$1 [NC,L]


select * from table where category='cricket'
RewriteRule ^live/([0-9a-zA-Z]+)$ live/index.php?category=$1 [NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM