我试图从我的 CI url 中删除 index.php,但按照说明它似乎不起作用。
我在子目录中运行了一个 codeigniter 安装。在路由配置中设置了一个名为 main 的默认 Controller ,另一个名为“create”的 Controller 。默认运行良好,但转到/create 会返回 324 错误,指出未收到数据。我的 htaccess 看起来像这样:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
最佳答案
这应该足够了:
<IfModule mod_rewrite.c>
RewriteEngine On
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
关于.htaccess - 使用 htaccess 删除子目录中的 codeigniter index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6765883/