php - Multi Domains for Codeiginiter

73

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

  • member
  • admin

i am access to these folder like this

http://example.com/member
http://example.com/admin

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

http://member.example.com
http://admin.example.com

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

451

Answer

Solution:

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

You create your subdomains: member.site.com & [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} !^admin.site.com$ [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} !^member.site.com$ [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 admin.site.com 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.

917

Answer

Solution:

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

Source

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.