我有像
这样的链接结构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=
,以便网址显示为人性化。
请帮我设置htaccess吗?
答案 0 :(得分:1)
这是一个非常基本的设置.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]
这应该启用像
这样的网址http://example.com/first
http://example.com/first/second