.htaccess not working on codeigniter subdomain & directory install

独自空忆成欢 提交于 2020-01-06 12:08:31

问题


I am trying to install CI under a directory which is also on a subdomain. So my base url would look like http://subdomain.domain.com/ci/

The following htaccess works fine on root of domain but not on directory, the browser says there is a redirect loop error.

Here is my code:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^sub\.domain\.com/ci/$
RewriteRule ^(.*)$ http://sub.domain.com/ci/$1 [L,R=301]

RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /index.php?/$1 [L]

I am not very skilled with mod rewrite, any help would be appreciated! Thank you!


回答1:


Inside your /ci directory your htaccess should be as follows

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f # this means if the requested file name doesnt exist 
RewriteCond %{REQUEST_FILENAME} !-d # this means if the requested directory doesnt exist 
RewriteRule ^(.*)$ index.php [L]

Based on your above comments that should be sufficient



来源:https://stackoverflow.com/questions/11384554/htaccess-not-working-on-codeigniter-subdomain-directory-install

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