我有一个类似的链接结构
http://www.example.com/folder/index.php?dir=
http://www.example.com/folder/index.php?dir=first/
http://www.example.com/folder/index.php?dir=first/second/
等等。
我想隐藏index.php?dir=
,这样URL看起来对人类友好。
请帮我设置htaccess?
这是.htaccess&mod_rewrite:
RewriteEngine On
# Don't rewrite if the file or directory actually exists
# protects against a rewrite loop if index.php is hit
# and allows css, js, images not to be messed with
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite everything to the dir=parameter, appending any existing querystring with QSA
RewriteRule ^(.*)$ index.php?dir=$1 [L,QSA]
这应该启用类似的URL
http://example.com/first
http://example.com/first/second