我正在尝试对查询字符串进行非常简单的重写
http://www.example.com/directory1/directory2/test.php?id=8
到
http://www.example.com/directory1/directory2/test/8
我的代码是
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?test/(.*?)/?$ /test.php?id=$1 [L]
坚果它不工作我也尝试在stackoverflow上提供许多解决方案,但没有任何工作,请帮助我
答案 0 :(得分:1)
将此规则放在/directory1/directory2/
Options -MultiViews
RewriteEngine On
RewriteBase /directory1/directory2/
RewriteCond %{THE_REQUEST} /test\.php\?id=([^\s&]+) [NC]
RewriteRule ^ test/%1? [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/(\w+)/?$ test.php?id=$1 [L,QSA,NC]