我是 codeigniter 的新手,我正在尝试从 Codeigniter 的 URL 中删除 index.php 但无法执行此操作。 我在 .htaccess 文件中编写了代码-
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
我的 Apache mod_rewrite 已启用。
但是当我试图在不使用 index.php 的情况下访问任何 Controller 时仍然出现 404 错误。
请帮忙。
谢谢。
最佳答案
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
</IfModule>
是我正在使用的代码,它适用于我使用过的每个托管平台。
关于php - 无法从 codeigniter 中的 URL 中删除 "Index.php",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29205468/