Can i direct user to a specific folder depending on what domain they requested?
I have several domains at no-ip.org, lets say NAME1.no-ip.org and NAME2.no-ip.org. In my default web folder i have two sub folders, one of each of the domains. Could I in any way redirect them to the correct folder depending on what domain they are trying to browse?
If it matters i have set up ISS7 with PHP :-)
if ($_SERVER['HTTP_HOST'] == "NAME1.no-ip.org")
header("Location: /right/folder");
BTW Look also how to deal with virtualhost and IIS7.
Usually this kinds of redirection are made by the webserver itself if well configured
Related
I have registered a wildcard subdomain record for the dir /.../public_html/hosting/accounts/. When a user requests a hosting space, I generate a folder in accounts. My index.php (which is also the 404 ErrorDocument) in accounts uses some basic PHP code to determine the subdomain and the path. Using display the file using include({subdomain}/{requested file}).
Therefore, demo.example.com/file would trigger a 404 and the index.php will display the file at example.com/hosting/accounts/demo/file.
I am, however, concerned that the users would be able to access the files of others via get_file_contents, include, exec and etc.
Is this the correct way to provide hosting on a subdomain? Is there another way to do it?
Any assistance would be appreciated!
So, i'm a total noob with codeigniter but i'm getting by.
I have a domain name on iPage. Currently, I am using codeigniter w/ my codeigniter project inside htdocs which is inside XAMPP. Everything is working great on localhost, but I am totally lost on where to start concerning how to put my project onto my web hosts server.
There is not much to it.
The following part, does not really belong here, but I guess I like to start from the beginning.
You need a domain name and hosting space(with a php server ofcourse).
The hosting provider will provide you with ftp access and a control
panel to access your files. You need to add nameservers to your
domain name to associated it with your hosting space.
www.yourdomain.com/ will point to your hosted files. (This might take a couple of days to take effect).
To answer your question:
Now, you can simply upload the contents of your project to your home
directory on the hosting server. You can organize it the way you want
with subfolders etc. You'll also need to make server specific changes
like mentioned here
You might also need to check if any php libraries need to be enabled on your server.
CodeIgniter is installed in four steps:
Unzip the package.
Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.
If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.
If you wish to increase security by hiding the location of your CodeIgniter files you can rename the system and application folders to something more private. If you do rename them, you must open your main index.php file and set the $system_path and $application_folder variables at the top of the file with the new name you’ve chosen.
For the best security, both the system and any application folders should be placed above web root so that they are not directly accessible via a browser. By default, .htaccess files are included in each folder to help prevent direct access, but it is best to remove them from public access entirely in case the web server configuration changes or doesn’t abide by the .htaccess.
If you would like to keep your views public it is also possible to move the views folder out of your application folder.
After moving them, open your main index.php file and set the $system_path, $application_folder and $view_folder variables, preferably with a full path, e.g. ‘/www/MyUser/system’.
Reference: https://www.tmdhosting.com/codeigniter-hosting.html
I own a website which gives every registered user a dedicated space like this:
www.mywebpage.com/user1
www.mywebpage.com/user2
www.mywebpage.com/user3
Inside this path the user has his mini web site.
I'd like to give my users not a path within my domain, but a second level domain like this:
user1.mywebpage.com
user2.mywebpage.com
user3.mywebpage.com
A lot of websites do this, but I can't figure out how to get it!
Am I supposed to register a CNAME in my dns record for every single user? How the hell can I achieve this with PHP? I don't think it's possible to configure godaddy with a human-hand written script.
I may register an alias CNAME which points every second level domain to my top domain, and then check within my top domain the first token of the url retrieving the user: but now I can't redirect him on a new page (which is the index of his subsite) or I'd lost the web url userx.mywebpage.com.
How can I handle this? I'd appreciate any hint about the right path to follow in order to achieve my goal.
Create a wildcard A record (*.mywebpage.com) pointing to the IP of your server.
Create an Apache virtual host for ServerName *.mywebpage.com, pointing all requests to the same document root. Your script looks at the hostname to know which user's site it is. You do not need to redirect outside of the user's subdomain. If your script sees the subdomain is "www", that's your special case where you display the main website instead of the user's stuff.
The feature you want to see is often called Wildcard sudomain (usually blog sites have this feature).
Usually you make a CNAME record of * to represent the wildcard subdomain. Instead, with Godaddy make an A record with the name * and set the IP to your server. We have done with our ASP.net website in the past (not sure if works with GoDaddy still but give a try).
With a very little knowledge on PHP I can suggest adding some redirection(URL Rewrite) configuration in your httpd.conf or apache.conf file.
Please check this
http://kbeezie.com/view/wildcard-subdomains-php/
after this you can write your own logic. All you need to do is find out your user from db which is in the subdomain name and render the pages.
You don´t have to set up dns entries for what you´re trying to achive. Depending on how much control you have over your website, in case you´re using Apache you can easily set up virtual hosts for your subdomains (see http://content.websitegear.com/article/subdomain_setup.htm)
if I like to create per user sub domain , how technically do I do this ?
for example if user XXX is registered to my site and I what to associated him the sub domain http://xxx.mydomain.com/
or http://www.mydomain.com/xxx/
what is the procedure to make it ?
You need to setup a wildcard DNS record to catch all subdomains and send them to you web server.
Then you need to setup Apache to catch all named virtual hosts and send it to a directory.
In the directory you would set htaccess to send all requests to one script which would read the sub domain from the server variables and handle it accordingly.
If you want mydomain.com/xxx, then that's just a folder. Some hosts will also take mydomain.com/xxx and automatically make xxx.mydomain.com point to it without needing any configuration on your part. Might want to check that this isn't already the case for you.
How would you create the subdomain manually?
Good. Now automate it.
Currently I have a .htaccess file within the directory of the folder I want to restrict, with the appropriate group that has access to it.
What I want to do is have one htaccess for the entire site, and restrict groups to specific URL's.
So I want staff to have access to:
/staff/..
and Students to have access to:
/students/..
I would prefer restricting by URL in the htaccess file, so I do not have to do it in the virtual host conf file, and restart service each time.
so i am guessing that your picking up the group from LDAP .. so as ur using PHP .. i am guessing u would have a top level include file for db connections etc. So u can pick up their group from the LDAP,store in session and in the include .. check that REQUEST_URI always goes to their relevant folder e.g /$_SESSION[group]/ .. if not redirect them there.
With htaccess, AFAIK, you would need a new htaccess for each of those folders. You could just create users with the same un/pw for each of the folders for continued access, but they would need to log in more than once.
Since you have this tagged under php, I can give you a better php solution :) Simply prompt the user for un/pw and create a session to set loggedin = 1 and you're good to go. If you want to make this secure, you should do it via db and include some sort of md5 security code in the session as well.