trouble with utf-8 chars & apache2 rewrite rules

前端 未结 6 1988
南方客
南方客 2021-02-19 23:46

I see the post validating utf-8 in htaccess rewrite rule and I think that is great, but a more fundamental problem I am having first:

I needed to expand to handle utf-

6条回答
  •  被撕碎了的回忆
    2021-02-20 00:38

    This solution is based on: http://www.dracos.co.uk/code/apache-rewrite-problem/

    Try this rewrite rules:

    AddDefaultCharset UTF-8
    RewriteEngine On
    RewriteCond %{THE_REQUEST} /puzzle/([^?\ /]+)
    RewriteRule ^puzzle/(.*)$ puzzle.php/%1 [L]
    

    How to get the query param:

    g: $g

    "; // Test if '/' is present in URL for 404's $g2 = substr($_SERVER['REQUEST_URI'], 8); if (strpos($g2, '/') === false) { // do stuff } else { // Send 404 header here echo "

    404

    "; } ?>

    With this solution you have to send the 404 from php.

提交回复
热议问题