简体   繁体   English

如何在Codeigniter中使用.htaccess将404页面重定向到首页?

[英]How to redirect 404 page to homepage using .htaccess in codeigniter?

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

When I am doing login it redirects me on the dashboard page and when I do log out from the dashboard it takes me out from the dashboard to home page which is fine. 当我登录时,它会将我重定向到仪表板页面,而当我从仪表板注销时,它会将我从仪表板带回到主页,这很好。 Now what happens If I copy the link of the dashboard page and log out from the dashboard and after I put the dashboard URL directly it shows me another page as mention below: 现在会发生什么,如果我复制仪表板页面的链接并从仪表板注销,然后直接放置仪表板URL,它将显示另一个页面,如下所述:

http://freelancer.com/?/base_urllogin

I do not define base_urllogin anywhere in my code but I don't know where it comes from. 我没有在代码中的任何地方定义base_urllogin ,但是我不知道它来自哪里。 Please help me. 请帮我。

Thank You 谢谢

在您的.htaccess文件中添加以下代码,并将http://www.example.com替换为您要将错误404页面重定向到的URL。

ErrorDocument 404 [http://www.example.com][1]

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

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