【问题标题】:Rewrite Rules in Htaccess在 Htaccess 中重写规则
【发布时间】:2012-04-12 12:42:36
【问题描述】:

htaccess 新手:如何为此编写重写规则,
而不是 http://www.x.com/directory.php?state=TX 有 www.x.com/texas-fishing
而不是 http://www.x.com/directory.php?state=WA 有 www.x.com/washington-fishing

实际上 $1 表示 Url 的动态部分,例如(TX,WA..),但这里我需要页面的完整标题。所以我需要在脚本中修改还是 .htaccess 足以管理。 如果足够了,那我们如何管理..

【问题讨论】:

    标签: php .htaccess mod-rewrite


    【解决方案1】:
    RewriteRule ^texas-fishing$ directory.php?state=TX  [NC,L]
    RewriteRule ^washington-fishing$ directory.php?state=WA  [NC,L]
    

    【讨论】:

    • 首先感谢您的回复...实际上基于 id 我想显示页面标题但我想从 url 中隐藏 id 而不是 X.com/Test-Blog/466 有 X.com/Test-Blog 。 RewriteRule ^([a-zA-Z0-9-]+)/([0-9]+)$ /view-blog.php?blog_title=$1&blog_id=$2 我用过这个..
    猜你喜欢
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多