php - Multi Domains for Codeiginiter


hi we have a project on codeigniter PHP in my controller have two folder

  • member
  • admin

i am access to these folder like this

but i want not anyone access like above domain to these folder if any one access like above domain its show a 404 error page

i want anyone access these folder to help of subdomain like

my question is how to create sub domain for different folder in codeigniter folder and how to show error 404 page for above question




One way to achieve this would be using wildcard subdomains as @Sagar Khatri mentioned or specific subdomains and HTACCESS.

You create your subdomains: & [email protected]

Now using HTACCESS file (which is an Apache configuration file) we will restrict access for these subdomains

# dont allow acces to the admin controller not under the admin subdomain
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteCond $1 ^index.php/admin/(.*) [NC]
RewriteRule (.*) http://%{HTTP_HOST}/your-404-page

And the same for the member controller

#dont allow acces to the member controller not under the member subdomain
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteCond $1 ^index.php/member/(.*) [NC]
RewriteRule (.*) http://%{HTTP_HOST}/your-404-page

Remember that once you have the subdomains, if you dont restrict it, users that come to the site under will be able to see all other pages of the site (except members controller) , if you want to restrict their access just to admin controller you will have to add another rewrite rule.




just do this

$config['base_url'] = '';

in config.php for your app and start up

People are also looking for solutions to the problem: php - Get data from dropbox


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.