【问题标题】:RewriteRule not working for some links in XAMPP apacheRewriteRule 不适用于 XAMPP apache 中的某些链接
【发布时间】:2017-09-04 02:53:48
【问题描述】:
RewriteEngine On   
RewriteRule ^home/?$ pages/forum_html.php [NC,L] 
RewriteRule ^forum-thread/([A-Za-z0-9]+)/?$ pages/forum_thread_gen_html.php?thread_id=$1 [NC,L]  

我正在尝试进行内部 URL 重定向。第一个 RewriteRule 工作正常,但第二个不起作用,页面显示找不到对象,但是当我将第二行更改为 ^forum-thread/?$ 时,页面显示,但我的页面当然没有要处理的 id。

有人知道会发生什么吗?

第二个网址如下所示:

localhost/rootfolder/projectfolder/forum-thread/cdjd2_dsdsd4_adsda/

【问题讨论】:

  • 能否请您提供一个您请求的应由该命令重写的示例 URL?
  • 您尝试捕获的内容的示例网址会很棒。
  • 有点猜想,但是...听起来第二条规则有效,但您可能在图像、CSS 和/或 JS 方面存在相对 URL 问题?
  • 我终于找到了问题所在。 url 有下划线,而我使用的模式匹配序列中没有下划线。我已经编辑了第二个 RewriteRule: RewriteRule ^forum-thread/([A-Za-z0-9-_]+)/?$ pages/forum_thread_gen_html.php?thread_id=$1 [NC,L]
  • @FananDala 如果您在最初的问题中包含了请求 URL,那么这将是一个容易的地方。您应该将其添加为答案并接受时间(您可能需要稍等片刻才能接受)。

标签: apache .htaccess mod-rewrite xampp


【解决方案1】:

URL 有下划线,而我使用的模式匹配序列中没有下划线。我已经编辑了第二个 RewriteRule : RewriteRule ^forum-thread/([A-Za-z0-9-_]+)/?$ pages/forum_thread_gen_html.php?thread_id=$1 [NC,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 2018-03-16
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    相关资源
    最近更新 更多