CodeIgniter .htaccess RewriteRule导致404页面未找到 [英] CodeIgniter .htaccess RewriteRule result in 404 Page Not Found

查看:223
本文介绍了CodeIgniter .htaccess RewriteRule导致404页面未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下 .htacces 从旧页面路由到新页面:

I used the following .htacces to route from an old page to a new one:

RewriteEngine on
RewriteCond %{REQUEST_URI} /Uploader2.7.0/secureFileUploader.php
RewriteRule ^(.*)$ /uploader/upload [L,QSA]  

即使重写规则正确,我也收到了一个404页面未找到错误 。 .htacces 位于我网站的根目录。

Even though the rewrite rule is correct, I got a '404 page not found' error. This .htacces is at the root of my site.

基于这个答案,我更改了:

$config['uri_protocol'] = 'AUTO';

$config['uri_protocol'] = 'REQUEST_URI';

这使得重新路由规则正常工作,但是CLI停止工作。然后,我看到此问题,如果我将'uri_protocol'改回

And that made the reroute rule work fine, but the CLI stopped working. Then I saw this question which says it will work if I will change the 'uri_protocol' back to

$config['uri_protocol'] = 'AUTO';

是否有办法使这两种方法都起作用?

Is there a way to make both work?

注意:重写规则起作用,问题是与CodeIgniter内部路由。我可以使用 RewriteRule 规则或CLI,而不是两者。

Note: the rewrite rule works, the issue is with the CodeIgniter internal routing. I can make it work either with the RewriteRule rule or with CLI, not both.

我希望网址 /Uploader2.7.0/secureFileUploader.php 成为<$ c $

I want the url /Uploader2.7.0/secureFileUploader.php to become /uploader/upload internally, which i managed to do using the rule above.

/ uploader / uploader / upload code>在路径Codeigniter index.php 上传是我想控制器的名称

/uploader in the path of Codeigniter index.php, and upload is the name of the controller I wish to route to.

/ uploader 下,我有 .htaccess 文件隐藏CodeIgniter的 index.php ,它完美地工作:

Under /uploader I have the .htaccess file to hide the index.php of CodeIgniter, which works perfectly:

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


推荐答案

将.htacces文件放在同一级别的应用程序user_guide文件夹。
所以你的codeigniter文件夹中共有6个文件,包括index.php和许可证文本文档以及.htaccess文件。

put your .htacces file at same level of application, user_guide folder. So u have total 6 file in your codeigniter folder including index.php and license text document as well as .htaccess file.

这篇关于CodeIgniter .htaccess RewriteRule导致404页面未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆