【问题标题】:mod_rewrite help in localhost本地主机中的 mod_rewrite 帮助
【发布时间】:2012-09-09 16:53:57
【问题描述】:

我有一个带有 xampp 的本地网站,我想将此网址 localhost/mysite/frontend/article.php?article_id=something 转换为 localhost/mysite/frontend/article_id/something。我使用此重写规则

RewriteRule ^([A-Za-z0-9-]+)/?$ article.php?article_id=$1 [L] 

但不正确。有人可以帮忙解决一下吗。谢谢。

【问题讨论】:

    标签: mod-rewrite xampp localhost


    【解决方案1】:

    对于 http://localhost/mysite/frontend/article_id/something 如果 .htaccess 在 mysite 目录中并且某些内容被忽略

    RewriteRule ^frontend/([^/]+)/ /mysite/frontend/article.php?article_id=$1 [L] 
    

    【讨论】:

    • .htaccess 是前端目录,此规则不适用于 ^frontend。
    • 如果.htaccess在frontend目录下,使用RewriteRule ^([^/]+)/ /mysite/frontend/article.php?article_id=$1 [L]
    【解决方案2】:

    试试这个:

    RewriteBase /mysite/frontend/
    RewriteRule ^([A-Za-z0-9-]+)(/(.*?))?/?$ article.php?$1=$3 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多