Codeigniter sub-folder multiple controllers

末鹿安然 提交于 2019-12-24 13:13:40

问题


Here is my htaccess file and it works somewhat. Not matter what controller I specify it always goes to the home page

<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|css|js)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

This is my website URL

http://automationmetrics.local/automation/

Thoughts?


回答1:


The first two rules get triggered on all the files, just like it says in the comment. So this one:

RewriteCond $1 !^(index\.php|css|js)

seems redundant and removing it should solve the issue you're having.




回答2:


Some things I usually check when this happens to me:

  • Have I enabled the mod_rewrite module in Apache?
  • Have I set $config['index_page'] to blank?

If the above works, here's the one that I use, that's working on my end:

https://gist.github.com/petrepatrasc/6925413

If you're STILL out of luck, then try fiddling with the $config['uri_protocol'] parameter - I remember that I could only get it to work on Windows (with IIS at the time) using REQUEST_URI as a value. Might be related to that.



来源:https://stackoverflow.com/questions/19305792/codeigniter-sub-folder-multiple-controllers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!