我一直在尝试来自该站点的各种解决方案,但似乎都不起作用。我目前正在使用 hostgator 托管。这是我当前的 .htaccess 文件:
<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
没有运气。有谁知道为什么这不起作用?
最佳答案
这是您可以在 .htaccess(在 DOCUMENT_ROOT 下)中用于从 URI 中删除 index.php 的代码:
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]
关于regex - 使用 .htaccess 从 URL 中删除 'index.php',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9608366/