Welcome Guest, Not a member yet? Register   Sign In
Using base_url() on my new host.
#1

[eluser]Xarren[/eluser]
I'm just attempting to migrate my project onto a live host. One problem I have is that any use of base_url() function returns "http://localhost/". Now that's not exactly helpful when I'm trying to reference my files and other web pages.

Any tips on how to get it to work? I'm sincerely confused, this is the first time I'm hosting a codeigniter website up, and it just refuses to work for me.
#2

[eluser]pbreit[/eluser]
Check your config.php:

$config['base_url'] = BASE_URL;
#3

[eluser]Xarren[/eluser]
Ahh thank you, that fixes that issue, however now I am left with "http://www.discreetdelights.co.uk/css/admin_style.css" as my css link, which does not work. How do I need to reference to a file on my remote host? The actual location of that file is "home/discreet/public_html/discreetdelights.co.uk/admin/css/admin_style.css". Please bare with me, it is the first time I'm doing this.
#4

[eluser]pickupman[/eluser]
It depends on where you have CI installed. It is best to reference your assets(js/css) using absolute url's. You would use something like:
Code:
<link rel="stylesheet" type="text/css" href="/admin/css/admin_style.css" />

Putting a / in the front of the path says always add domain name(discreetdelights.co.uk) to the front of the url. This will work both on localhost and server.
#5

[eluser]Xarren[/eluser]
That still doesn't work. I'm a bit confused on how to access that file from that host.

my folder structure is as follows
i have public_html
which contains system, index.php, admin.php and discreetdelights.co.uk
system has the CI installation and discreetdelights.co.uk has admin and public

Could you please help me make some sense out of this, the difference between the servers path and the access url path is confusing me.
#6

[eluser]pickupman[/eluser]
It's not working because of your .htaccess file I am guessing
Both
http://discreetdelights.co.uk/css/admin_style.css
http://discreetdelights.co.uk/admin/css/admin_style.css

Return a CI 404 error. You won't be able to make the <link> tag yet. You should be able to type in the exact web address of the stylesheet in your browser and have it open up. Could you post the .htaccess file you have in /home/discreet/public_html/discreetdelights.co.uk/?
#7

[eluser]Xarren[/eluser]
Thank you for all your attention, I hate how a fullblown project which worked perfectly on my localhost got ripped to pieces, and Im up at 2am trying to fix it. fml.

Code:
RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
#8

[eluser]Xarren[/eluser]
Ahh that makes sense.. I need to add bits for admin.php aswell, let me try that.
edit: Im not 100% confident with HTACCESS, could you please help me make one that will work using both my index files, public.php and admin.php?

I only just seperated the website into those two parts, and forgot to edit my HTACCESS.
#9

[eluser]pickupman[/eluser]
Are you running multiple domains from the same account? I know this is typically the folder structure when you create an addon domain through cPanel. Any particular reason for creating the 2 separate applications that need index.php and admin.php. Your description of your folder layout is confusing. Try like or take a capture:
/public_html
/application
/system
/index.php
/public.php
/admin.php
/discreetdelights.co.uk
/admin.php

Maybe this would work
Code:
RewriteEngine On
RewriteBase /
##Create rules for admin.php application
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^admin.*
    RewriteRule ^(.*)$ admin.php/$1

##Create rules for public application
    RewriteRule ^(.*)$ index.php/$1 [L]
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

Or if all else fails, delete the .htaccess file, work out the file paths then add it back in. Remember .htaccess in subfolders take priority over its parent folders' .htaccess file.
#10

[eluser]Xarren[/eluser]
I separated it because of how different the admin and the public view sections are, I thought it would be easier to upkeep if there were in two different parts, however this is my first CI project, have you got any suggestions on how to organise it?

Code:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

thats trying to access admin with that HTACCESS. I will try to reorganise my files back into one application, and see if thats easier to work with.

thank you for your help.




Theme © iAndrew 2016 - Forum software by © MyBB