dongpu3898 2014-08-28 09:46 采纳率: 100%
浏览 132

CodeIgniter .htaccess RewriteRule导致404 Page Not Found

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]  

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

Based on this answer, I changed:

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

to

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

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?

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.

EDIT:

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

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

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]  
  • 写回答

1条回答 默认 最新

  • duanpo7354 2014-08-28 13:38
    关注

    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.

    This image is useful for you

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致