从具有的.htaccess URL删除“的index.php”
问题描述:
我一直在尝试各种从本网站解决方案,并没有似乎工作。我目前的托管与HostGator的。这是我目前的.htaccess文件:
I've been trying all sorts of solutions from this site and none seem to work. I'm currently hosting with hostgator. This is my current .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/user/php.ini
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>
这是在我的网站的根文件夹。我也尝试添加?
在的index.php
并没有运气。有谁知道这是为什么不工作?
This is in the root folder of my site. I have also tried adding a ?
after index.php
and no luck. Does anyone know why this isn't working?
答
这是在code,你可以在你的.htaccess(下DOCUMENT_ROOT)用于从URI删除的index.php:
This is the code you can use in your .htaccess (under DOCUMENT_ROOT) to remove index.php from URI:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]