我可以将网址localhost/web1/index.php?page=home
重写为localhost/web1/home
但我无法将网址localhost/web1/index.php?page=property_details&pid=1008&aid=283
重写为localhost/web1/property_details/1008/283
以下是我使用过的代码:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /web1/
RewriteCond %{THE_REQUEST} \s/+web1/?(?:index\.php)?\?page=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]