【问题标题】:.htaccess Question mark allowing.htaccess 问号允许
【发布时间】:2014-10-18 14:47:54
【问题描述】:

你好今天我尝试重写一些东西,我尝试重写这个:

www.example.com/index.php?title=how+do+man+live?

收件人:

www.example.com/posts/how+do+man+live?/

现在的问题是问号只出现在 url 上,当我发布 $_GET 变量(标题..)时,它会发布所有内容,但不是问号。

我尝试过重写 mdoe 这个:

RewriteRule post/([0-9א-בa-zA-Z+.`?]+)/?$ index.php?title=$1 [NC]

重写引擎已打开。 谢谢你们,祝你们有美好的一天!

【问题讨论】:

    标签: .htaccess mod-rewrite redirect rewrite url-rewrite-module


    【解决方案1】:

    您需要从THE_REQUEST 变量中捕获此值,才能同时捕获?。在根 .htaccess 中使用此规则:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+posts/(\S+) [NC]
    RewriteRule ^ index.php?title=%1 [L,QSA]
    

    【讨论】:

    • 非常感谢。但现在 url 对 / 的出现很有意义,我的意思是:example/posts/how+are+you?/ work 和 example.com/posts/how+are+you?不工作
    • 我觉得[B]这里也应该通过:httpd.apache.org/docs/2.4/rewrite/flags.html#flag_b
    • 实际上,在发布此答案之前,我已经使用B 和没有B 进行了测试。使用B 标志$_GET['title'] 变为how+do+man+live?/ 并且没有B 它出现how do man live?/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 2019-03-03
    • 2010-11-19
    • 2017-02-20
    • 2016-05-02
    • 1970-01-01
    相关资源
    最近更新 更多