这是我的mod重写代码(.htaccess)
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^test/(.*)$ /test.php?id_val=$1 [L]
DirectoryIndex index.php
当我尝试访问https://www.example.com/test/12345
它将重定向到https://www.example.com/test.php?id_val=12345
我该怎么办?
答案 0 :(得分:0)
更改规则的顺序并稍微修改一下代码:
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^test/(.+)$ /test.php?id_val=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]