我试图通过访问目录而不实际引用index.php重写URL
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}\ .php -f
RewriteRule ^([a-zA-Z]+) /?page=$1 [NC,L]
基本上,我正在尝试:
Change:
localhost/?page=Main
To:
localhost/Main
答案 0 :(得分:1)
RewriteEngine on
RewriteCond %{REQUEST_METHOD} GET
RewriteRule ^/?page=(.*)$ /$1
应该可以,但是您需要启用重写模块
答案 1 :(得分:1)
这有效。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/*([a-zA-Z]+) index.php?page=$1 [NC,L]