关于 apache:使用 PHP 获取值的简单 mod 重写 | 珊瑚贝

Simple mod rewrite with PHP Get values


谁能告诉我我到底做错了什么?

试图采取:

1
search.php?key=23&category=testing

并制作:

1
/23/testing.html

用这个:

1
RewriteRule ^([^/]*)/([^/]*)\\.html$ /?key=$1&category=$2 [L]

对于我的生活,我无法解决这个问题……或者如果有更好的方法,请指出正确的方向。

** 更新

好的,在放弃这个之后,我终于联系了托管公司,看看我的域是否有问题导致它无法正常工作。这是他们告诉我的:

  • You do not have a rewrite condition and you only have a simple rewrite. For the code to >always work properly you should normally set a”RewriteCond” with a valid pattern.

  • You have used the”?” question mark character in your code although this is an escape >character and doing so would only cause a rewrite to index.php based upon your code as >everything after the question mark gets escaped.

  • Please consider using a”RewriteCond” in your code and also use regexes to properly escape >the”?” character and avoid unexpected behavior.

    谁能帮帮我?谢谢!

    • 确保将 R 放入参数 [L,R] 中。我通常构建一个快速的自定义 MVC 并让每个请求都通过 index.php。这样我就可以编写出我的永久链接。
    • 仍然没有骰子。我不需要对我的 PHP 文件做任何其他事情吗?我可以得到一个简单的 hmtl 重定向来工作,所以我知道路径等正在工作……但对于我的生活,我无法弄清楚为什么这不起作用..
    • 我相信重写规则应该以 ^/ 开头。


    1
    RewriteRule ^/([^/]*)/([^/]*)\\.html$ /?key=$1&category=$2 [L,R]

    来源:https://www.codenong.com/13671955/

    微信公众号
    手机浏览(小程序)

    Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

    Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

    Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9335.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
    0
    分享到:
    没有账号? 忘记密码?