【问题标题】:.htaccess not redirecting?.htaccess 不重定向?
【发布时间】:2012-06-03 23:12:35
【问题描述】:

我有以下 .htaccess 文件:

RewriteRule ^s/([a-zA-Z]+) /servers/page.php?name=$1

RewriteRule ^s/([a-zA-Z]+)/new-thread /servers/new-thread.php?name=$1

从第一行可以看出:

mydomain.com/s/hello实际上向我显示了页面mydomain.com/servers/page.php?name=hello的内容

第二行:

mydomain.com/s/hello/new-thread 应该显示页面内容:mydomain.com/servers/new-thread.php?name=hello,

但是当我输入后一个 URL 时,我会得到前一页的内容。

这意味着如果我输入mydomain.com/s/hello/new-thread,我会显示内容,就像我输入mydomain.com/s/hello一样。有人可以向我指出为什么会这样吗?提前谢谢!

【问题讨论】:

    标签: php mysql html apache


    【解决方案1】:

    试试这个:

    RewriteRule ^s/([a-zA-Z]+)/new-thread /servers/new-thread.php?name=$1 [L]
    RewriteRule ^s/([a-zA-Z]+) /servers/page.php?name=$1 [L]
    

    【讨论】:

    • [L] 是什么意思,有什么作用?
    • @Ken: 表示在此行之后不再处理任何规则。没有它,下一行只是处理它之前的行的输出。如果您不想区分大小写,可以使用[NC,L]
    猜你喜欢
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 2016-11-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多