dpd7195 2015-03-09 19:16
浏览 17
已采纳

htaccess cat / subcategory显示subcategory.php页面

I have the following path:

Root
--cp
----cursos-de-ingles.php
----ingles-general.php
----course-details.php

I have the following htacces rule:

RewriteRule ^cursos-de-ingles  cp/cursos-de-ingles.php [NC,L]
RewriteRule ^cursos-de-ingles/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]

if I navegate to /cursos-de-ingles I see the cursos-de-ingles.php with the list of course if I go to /cursos-de-ingles/nombre-de-curso I see the course-details.php?name=nombre-de-curso with the information of the course

And this is what I want, but now I have a sub category inside the /cursos-de-ingles, so I need the a htaccess rule to accomplish the following:

If I go to /cursos-de-ingles/subcategory/ I need to see the ingles-general.php page with the list of course in this category.

Also if I go to /cursos-de-ingles/subcategory/nombre-de-curso I need to see the course-details.php?name=nombre-de-curso with the information of the course

I was trying something like this:

RewriteRule ^cursos-de-ingles/ingles-general/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]

and this works perfect I see the course-details.php?name=nombre-de-curso with the correct information.

But when I go to /cursos-de-ingles/ingles-general I see the course-details.php?name=ingles-general with out information, because "ingles-general" is no a course name is a subcategory and it suppose to show me the ingles-general.php page.

this is what I'm trying:

RewriteRule ^cursos-de-ingles/ingles-general  cp/ingles-general.php [NC,L]
RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+) cp/ingles-general.php?name=$1&sub=$2 [NC,L]
RewriteRule ^([a-z0-9-]+)/ingles-general cp/ingles-general.php?name=$1&sub=$2 [NC,L]
RewriteRule ^([^\.]+)/([^\.]+)/([^\.]+)/$ /ingles-general.php?name=$1&sub=$2 [NC,L]

but nothing works.

Help pelase

  • 写回答

1条回答 默认 最新

  • duansaoguan7955 2015-03-10 04:09
    关注

    Try this:

    RewriteRule ^cursos-de-ingles  cp/cursos-de-ingles.php [NC,L]
    RewriteRule ^cursos-de-ingles/ingles-general  cp/ingles-general.php [NC,L]
    
    RewriteRule ^cursos-de-ingles/(?!ingles-general)([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
    RewriteRule ^cursos-de-ingles/ingles-general/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度