在这里,我想为我的网站的每个网址删除index.php?file =。我已经尝试了很多.htaccess的教程,但不幸的是创建了正确的.htaccess。
实际网址如下:
http://localhost/test/json/iscore2/index.php?file=home
http://localhost/test/json/iscore2/index.php?file=contact
然后我想这样做:
http://localhost/test/json/iscore2/home
http://localhost/test/json/iscore2/contact
答案 0 :(得分:2)
可能你已经在apache2中设置了重写模块
(sudo a2enmod rewrite
)
AllowOverride
和主机设置
我在iscore2
文件夹
<IfModule mod_rewrite.c>
RewriteEngine on
# Play with this if redirection fails
#RewriteBase /
# if it is not a file or folder, rewrite to index.php?file=<value>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?file=$1 [L,QSA]
</IfModule>