Answer the question
In order to leave comments, you need to log in
How to redirect a function to a subdomain in codeigniter?
Hello everyone
There is an address of this type that opens the user's page:
infoumnik.local/user_site/sub/user2
How to make the user's page open at this address?
http:// user2 .infoumnik.local/ Figured out
only how to make a folder
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.infoumnik\.local$
RewriteCond %{HTTP_HOST} (www\.)?(.*)\.infoumnik\.local$
RewriteCond %{REQUEST_URI} !user_site/sub/
RewriteRule ^(.*)$ user_site/sub/%2/$1
Answer the question
In order to leave comments, you need to log in
No way - you need a domain name, copy another codeigniter there, and make a controller and an action there, which will pull another one from the same base.
Or to cheat already with a server so that it requests you a file on a subdomain that lies in a completely different directory from the root one. I doubt that this is done by a simple redirect, because your htacess is responsible for the current folder, and you are at war with domain names.
The idea that is the simplest but stupid is to request a page on a subdomain with some kind of file_get_contents, but it will be damn inconvenient to work with this.
Alternatively, you can do something like this
$subdomain_arr = explode('.', $_SERVER['HTTP_HOST'], 2);
$subdomain_name = $subdomain_arr[0];
$this->db->from('user_site')->where('subdomain_name', $subdomain_name);
$query = $this->db->get();
$subdomain_info = $query->row();
if($query->num_rows() < 1)
{
redirect('blog');
} //иначе открываем вид
1) In dns, make sure that there is an A record for subdomains
2) make a wildcard virtual server *.infoumnik.local in your web server that looks at the folder with the current site
3) Do an internal rewrite in the web server config with * (except www) at infoumnik.local/user_site/sub/*
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question