Welcome Guest, Not a member yet? Register   Sign In
Subdomains and Codeigniter
#1

[eluser]JanDoToDo[/eluser]
Hi guys,

I have a website setup and a codeigniter installation at domain.com

I have setup a subdomain with another codeigniter system folder/isntallation as the subdomain is a totally different site, im just using it as a testing ground.

The site works on my localhost but when i move it to the server it tells me that it has encountered a database error and cannot connect using the provided settings. I don't know why this is because the database settings are correct and i can connect to the db if it isnt located in the subdomain. Ive checked the config and database files but everything seems fine.

Could the problem be that because it is on the same domain, it is still trying to use the primary codeigniter files and as such is conflicting somewhere? Is there a way around this?

thanks!! Smile
#2

[eluser]developer10[/eluser]
[quote author="JanDoToDo" date="1261893634"]Hi guys,

I have a website setup and a codeigniter installation at domain.com

I have setup a subdomain with another codeigniter system folder/isntallation as the subdomain is a totally different site, im just using it as a testing ground.

The site works on my localhost but when i move it to the server it tells me that it has encountered a database error and cannot connect using the provided settings. I don't know why this is because the database settings are correct and i can connect to the db if it isnt located in the subdomain. Ive checked the config and database files but everything seems fine.

Could the problem be that because it is on the same domain, it is still trying to use the primary codeigniter files and as such is conflicting somewhere? Is there a way around this?

thanks!! Smile[/quote]

your subdomain is within your domain.com, for which you set up the database settings?
#3

[eluser]JanDoToDo[/eluser]
Cheers for the response!

I am using a database which isnt used by the main website, and im using an ip address (as thought it was an external request) for the host instead of e.g. localhost just incase localhost didnt work.

If you need more info please ask ( I dont know what would be useful)
thankyou! Smile
#4

[eluser]developer10[/eluser]
[quote author="JanDoToDo" date="1261978295"]Cheers for the response!

I am using a database which isnt used by the main website, and im using an ip address (as thought it was an external request) for the host instead of e.g. localhost just incase localhost didnt work.

If you need more info please ask ( I dont know what would be useful)
thankyou! Smile[/quote]

maybe your host doesn't allow a remote access to mysql database, so that might be the reason you're getting that error

my suggestion is, if possible, to test it on a subdomain which belongs to a domain where your database is. that way, you'll be using "localhost" instead of IP address, and everything will be just fine
#5

[eluser]JanDoToDo[/eluser]
Have changed the host to localhost now but still no success. It just gives me the unable to connect to datbase error Sad
#6

[eluser]developer10[/eluser]
[quote author="JanDoToDo" date="1261980535"]Have changed the host to localhost now but still no success. It just gives me the unable to connect to datbase error Sad[/quote]

now i'm lost. look, if you have your mysql database on this domain: www.example.com, then for testing purposes create and use www.subdomain.example.com
(instead of a subdomain on some other domain), then of course leave "localhost" and everything else intact.

by the way, if there is some differences in your localhost mysql server settings (username and pass), make sure you dont use those, but use your live server's mysql
username and pass!
#7

[eluser]JanDoToDo[/eluser]
Im using the following:

sub.domain.com ( which is actually /home/public_html/sub/ )
db host/username/password all correct

in the .htaccess file in public_html/sub/.htaccess is :
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|errordocs|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

As its in a subdomain folder, do i need to change the rewrites? I havent done as I thought that with it being in a subdomain, the server should control the subdomain folder it points to? Also, I figured if it wasn't rewriting the URL's properly it wouldnt have even got that faar?
#8

[eluser]JanDoToDo[/eluser]
P.S. this IS all on the same domain, im not using databases on different domains.
#9

[eluser]JanDoToDo[/eluser]
Sorry for the confusion - in my first post, by "totally different site" i meant its a test ground for a different website so it isn't sharing any codeigniter system files
#10

[eluser]developer10[/eluser]
[quote author="JanDoToDo" date="1261981006"]P.S. this IS all on the same domain, im not using databases on different domains.[/quote]

try temporarily removing the .htaccess file
not sure, but you might also check if you correctly set necessary things in your CI application's config file (base path, etc)

those are things i would check for, anything else doesn't cross my mind

hope you'll find a solution!




Theme © iAndrew 2016 - Forum software by © MyBB