Welcome Guest, Not a member yet? Register   Sign In
Remove Public from URL
#1

(This post was last modified: 06-09-2020, 09:45 AM by jreklund.)

Hi Guys, 

I am new to CI and just diving in. Love it so far. 
However, I have setup a new Mamp environment and setup a new host of http://codeigniter/ and when I try to run codeigniter, I can only view it at /codeigniter/public/ . I have no issue with this during development but need to clean up the URL. 

I have read that you need to move index.php and .htaccess out of public to the root. However, this seems like a security issue. 

Whats the proper way to get the correct base URL? Also note, I already updated the .env file and app.php file to match http://codeigniter/

Any light on this would be great!
Reply
#2

This is something that needs to be changed in your Mamp. You got "codeigniter" set up by pointing it to a directory correct?

You need to append /public/ to the document root path in mamp and you will be good.
Reply
#3

(06-09-2020, 09:46 AM)jreklund Wrote: This is something that needs to be changed in your Mamp. You got "codeigniter" set up by pointing it to a directory correct?

You need to append /public/ to the document root path in mamp and you will be good.
Thanks so much!

I definitely was going to do this but after checking online, I saw others do it a different way.

However, I want to be sure I do it in the correct CI way. Big Grin
Reply
#4

Regarding moving the index.php, you may need to do that. In case your provider don't allow you to change document root. Here are some instruction to hide the other folders from prying eyes in cPanel.

https://forum.codeigniter.com/thread-759...#pid373901
Reply
#5

(06-09-2020, 12:13 PM)QUICKJEFF Wrote: I definitely was going to do this but after checking online, I saw others do it a different way.

However, I want to be sure I do it in the correct CI way. Big Grin

The "different way" is probably because they do not have access to the server configuration. That would be normal on a shared server from a service provider.

But you are using a MAMP setup and can define the server root to be any path you want. That path should be the CodeIgniter public directory.

Note that, as far a CodeIgniter is concerned, the directory does not need to be named "public". If you're MAMP setup insists on some particular name (e.g. "htdocs" or "public_html") that is ok. As long as your domain is set to serve out of that directory.
Reply
#6

(This post was last modified: 08-19-2020, 01:25 PM by jinbatsu.)

I use also MAMP, I actually point my docroot to add an additional folder public, so that all non-public folder and files are outside docroot and all in one folder structure.

For shared hosting, yes we should use some little configuration, to make it work as it should, like mentioned in this thread: https://forum.codeigniter.com/thread-76777.html

But for subdomain or add-on domain as a shared user in cpanel or directadmin or any modern panel, actually we can use additional folder to point the docroot, just like in MAMP.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB