开发者

Codeigniter redirect to a public_html folder

开发者 https://www.devze.com 2023-03-02 04:52 出处:网络
I want to place all my static assets (js, css, etc) in a separate folder \"public_html\". But of course I still want my url to be: http://www.domain.com instead of http://domain.com/public_html

I want to place all my static assets (js, css, etc) in a separate folder "public_html". But of course I still want my url to be: http://www.domain.com instead of http://domain.com/public_html

This can be done with .htaccess I suppose but haven't had a开发者_如何学Cny luck with it.

Also do I configure my base_url in codeigniter to be http://www.domain.com or http://www.domain.com/public_html

Thanks!


public_html is the folder on your server where you put your codeigniter files into. In your config file you set the base_url as be http://www.domain.com.

You can put the assets folder in the public_html folder and the url will still be http://www.domain.com.

Example file structure.

server
- www
- etc
- public_html
  - application
    - config
      - config.php
  - system
  - assets
    - css
    - images
    - js


Actually, I'm pretty sure it's a better pratice to have your system and application directory out of the public_html folder. Something like this:

- www
  - application
  - public_html
    - css
    - images
    - js
    - index.php
  - system

No codeigniter files but the index.php need to be in the public_html folder. You just have to point you index.php to them, adjusting 'system_path' and 'application_folder' in application/config/config.php.

In any event, it's safer for them not to be accessible externally. It's also discussed in the codeigniter wiki: http://codeigniter.com/wiki/Moving_your_app_out_of_DOCROOT/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号