douji9518 2014-10-17 22:10
浏览 44
已采纳

如何在url中删除两个获取id

now my url is

detail.php?category=abc&model=126

and i want like this

detail/abc-126.html

and i am using this code in but it is not working properly

.htaccess

RewriteRule ^detail/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ detail.php?category=$2&model=$2

and my 2nd question is suppose if i use a dir like this in my website foldername

www.example.com/foldername/detail/abc-126.html

and my php file in this folder

www.example.com/foldername/detail.php

and my .htaccess file in

www.example.com/.htaccess 

is here

so how can i use with foldername

and this is not a duplicate post i search many sites but i did not understand how to solve this

so please help me to fix this issue thanks

  • 写回答

2条回答 默认 最新

  • drtkyykai004574380 2014-10-17 22:21
    关注

    You have two conditions and you are referencing $2 twice instead of $1 & $2. So that is one problem. That probably won't solve your issue because I am not very good at rewrites, but it's a start.

    Also you are wanting abc-126.html but you have a forward slash in between your rewrite like so )/(.

    For your second question, I am not 100% sure what you are asking, but if the .htaccess file is in the parent directory, it's effect is felt through the children directories unless you put a new .htaccess file in the child directory.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100