Welcome Guest, Not a member yet? Register   Sign In
Newbie CI question
#11

[eluser]cahva[/eluser]
Dont include index.php to base_url. What would be the point doing that? If you havent used mod_rewrite to get rid of index.php, it is set with $config['index_page']. When using anchor(), site_url() etc. it is automatically added.

Also in the view files when you point to some picture(or css file or any other asset), you would use base_url() function to get the url to your ci app. For example:
Code:
<img src="&lt;?php echo base_url() ?&gt;images/foo.jpg" alt="">
Imagine if you had your index.php set in the base_url config.. You couldnt use that in your view files as it would give you false url to the image:
Code:
<img src="http://localhost/CI/test1/index.php/images/foo.jpg" alt="">
#12

[eluser]theprodigy[/eluser]
in the grand scheme of things, it may not make any difference. I'm sure I could look at the code and see that everywhere the echo the base_url config setting, they also echo index_page right after it (which is why you blank it out when using htaccess), but it's just a matter of doing it the right way. I can't guarantee that it will all work correctly every time in every instance if you add index.php to the end of base_url.

Did you read through the comments of that Netuts tutorial? Did someone straighten them out?

What is the link for that tutorial?
#13

[eluser]skaterdav85[/eluser]
Here is the link to the Netuts tutorial. If you watch the first couple minutes of the video, you see them install CI and change the config options.

http://net.tutsplus.com/tutorials/php/co...framework/
#14

[eluser]theprodigy[/eluser]
are you sure you posted the correct link? I'm not seeing where he put index.php in the base_url.
#15

[eluser]skaterdav85[/eluser]
ya it's the right link. It is at 20:18 though, not the first few minutes. My mistake. It is day 1, or you can go directly to the day 1 video here:

http://net.tutsplus.com/videos/screencas...tch-day-1/
#16

[eluser]theprodigy[/eluser]
You are correct. He did keep index.php in the base_url, but I think it was a mistake and not meant. He is probably used to using htaccess to remove index.php out of the url, and therefore didn't think about having to remove it from a copy/paste url. If you notice he did make a comment about the index_page config setting, and removing it if you use htaccess.

There were a couple people in the comments that I recognize from the forums here, and I'm surprised that they either didn't catch it, or didn't mention it if they did catch it.

Either way, do NOT put index.php in the base_url config setting. I couldn't think of any reasons before, but as cahva mentioned, it will throw off a good number of the url helper functions and html helper functions (like site_url, base_url, anchor, img, etc)
#17

[eluser]skaterdav85[/eluser]
ok good to know. I am also having trouble doing the mod rewrite so that i can remove the 'index.php'. I've searched through the documentation, the forums, and through Google and nothing seems to work. I am using MAMP to build my site. My site resides in a folder within htdocs called si

My .htaccess file looks like this:
Code:
RewriteEngine On
RewriteBase /si
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

In config.php, I have done the following:

Code:
$config['base_url'] = "http://localhost:8888/si/";
$config['index_page'] = "";

I attempted these same steps on my freind's PC using XAMPP and it worked, so I dont know why it is not working on MAMP. I looked at phpinfo() and under Loaded Modules I see mod_rewrite, so I believe it is being loaded. I have also stopped and restarted the server. Any ideas why it isnt working?

EDIT: Problem solved. For some reason when I brought the .htaccess file from my PC to the mac, the mac changed the file name to htaccess instead of .htaccess since files beginning with a "." are 'reserved for the system'.




Theme © iAndrew 2016 - Forum software by © MyBB