简体   繁体   English

无法从codeigniter中的URL中删除“Index.php”

[英]Not Able to remove “Index.php” from URL in codeigniter

I am new in codeigniter and i am trying to remove index.php from URL in Codeigniter but not able to do this. 我是codeigniter的新手,我试图从Codeigniter中的URL中删除index.php但不能这样做。 I wrote code in my .htaccess file- 我在.htaccess文件中编写了代码 -

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

My Apache mod_rewrite is enable. 我的Apache mod_rewrite已启用。

But still got 404 error when i am trying to access any controller without using index.php. 但是当我尝试访问任何控制器而不使用index.php时仍然出现404错误。

Please help. 请帮忙。

Thanks. 谢谢。

<IfModule mod_rewrite.c>
    RewriteEngine on 
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]
</IfModule>

Is the code I'm using, it works on every hosting platform I've used it on. 是我正在使用的代码,它适用于我使用过的每个托管平台。

This should help you, 这应该对你有帮助,

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

check this code of htaccess file. 检查htaccess文件的这段代码。

DirectoryIndex index.php    
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)    
RewriteRule ^(.*)$ index.php?/$1 [L]

you can find your answer refference here 你可以在这里找到你的答案参考

My .htaccess file is not working 我的.htaccess文件无效

moreover can you share your base url with us? 此外,您可以与我们分享您的基本网址吗? as this error may be due to wrong baseurl set. 因为这个错误可能是由于错误的基础设置造成的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM