简体   繁体   中英

CodeIgniter not working in sub-directory

I'm using CodeIgniter 3.1.1 .

The problem is when i browse sub-directory( http://www.wap.com/demosite ) where CodeIgniter installed, it always redirect to main domain and i think the problem is in .htaccess .

For example :

Domain : http://www.wap.com

Main site directory public_html/

And .htaccess file in main-directory public_html/.htaccess

RewriteEngine on
RewriteOptions inherit

ErrorDocument 500 /errors/404
ErrorDocument 401 /errors/404
ErrorDocument 403 /errors/404
ErrorDocument 404 /errors/404


RewriteCond %{HTTP_REFERER} !^http://wap.com/.*$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|js)$ - [F,NC]

CodeIgniter installation directory

public_html/demosite/

And .htaccess file in sub-directory public_html/demosite/.htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]  

I'm assuming the move is a new addition?

Need to make sure that in application/config/config.php that your base_url is set to http://www.wap.com/demosite not to http://www.wap.com

This is often missed and causes these kinds of redirects

Your codeigniter htaccess should also be set to RewriteBase /demosite/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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