【问题标题】:Htaccess blog slug Rewrite does not workHtaccess blog slug 重写不起作用
【发布时间】:2014-07-23 12:53:08
【问题描述】:

我正在尝试使用以下方法来获取页面的 url www.mysite.com/blog/this-an-article htaccess 代码:

  RewriteRule ^blog/([a-zA-Z0-9-/]+)$ blog/page.php?slug=$1  [NC,L]

所以这段代码不起作用,我得到 404 错误...找不到页面。 我有一个名为:blog 的子文件夹,其中包含 index.php 和 page.php。 你能帮我吗? 谢谢

【问题讨论】:

  • 定义“不起作用”。它做了什么,你期望它做什么?为您的问题添加更多详细信息,直到它的时间大约是现在的三倍。
  • 我收到 404 页面错误...找不到页面

标签: php .htaccess


【解决方案1】:

重写规则 ^/blog/([a-zA-Z0-9-/]+)$ /blog/page.php?slug=$1 [NC,PT,L]

尝试使用第一个斜杠“/”并查看标志“PT”

【讨论】:

  • 对不起:RewriteRule ^/blog/([a-zA-Z0-9-/]+)$ /blog/page.php?slug=$1 [NC,L] 使用第一个斜杠“/”在正则表达式和目标 url 中都有
  • 还是一样...找不到页面。感谢您提供帮助。
  • RewriteRule ^/blog/([a-zA-Z0-9-/]+)$ /blog/page.php?slug=$1 [NC,PT,L] 如果执行 /blog /page.php?slug=something-real 有用吗?
猜你喜欢
  • 2020-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-06
  • 2015-02-03
相关资源
最近更新 更多