I have seen sites that when you login it will look something like...
.example.localhost/blahblah.php
how is this possible with htaccess?
Any ideas
Do the files have to be placed in a seperate folder??
It's called sub-domain.
It has more to do with the DNS but htaccess can be used to modified its behavior.
Ie, point different sub-domain to the same folder.
Related
It's hard to explain, I would like to do something like below but I don't know how.
I currently own two different domain names and have one website.
Can I have two domains pointing to the same website but the URL only shows whatever domain is entered in the first place?
For example, when I type in 'domain123.com', it takes me to my website (IP address 111.222.333) with the URL shown as 'domain123.com'. Then when I type in 'domainABC.com', it also takes me to the same website (IP address 111.222.333), but the URL needs to show 'domainABC.com' instead of 'domain123.com'.
I guess I will need to redirect one of the two domains to the website, but how can I stop the URL changes the domain name?
I am not sure if I can just modify .htaccess to achieve above or if I also need to change the DNS, etc. to make this work.
Please help and many thanks
It depends on your setup and your server permissions.
A nice way will be to change the docroot in the apache or nginx config.
If you don't have permissions to edit these configs, you can create a symbolic links so that the public folder of domain2 points to the public folder of domain1
I have been searching and looking for the answer to this for SO long now without any joy, I hope someone can help.
Okay I have a web structure of:
Main folder - This is where you first land prior to logging in. After you log in you will be either directed to a number of websites that are resident in a sub-folder called websites. The problem I have is that I would like the document root, say the $_SERVER['DOCUMENT_ROOT'] variable, to default to the root of the website folder that it has been directed to. You see I have a lot of $_SERVER['DOCUMENT_ROOT'] in my php code and I use the '/' slash a lot in the href on my HTML tags.
I have seen that I could accomplish this by adding a .htaccess in the root of eiach website folder but 1, would like work for my situation and 2, could anyone please help me with the code. I understand I can use the RewriteRule command but I can't get my head around it. My folder stricture is like this:
login (index.html)
websites folder
website1 (index.html)
website2 (index.html)
website3 (index.html)
I have tried many versions of using RewriteCond etc but non of them work.
If anyone can help me out here I'd be very grateful.
Thanks
Nothing you can do in your htaccess file that's going to be able to change the document root. One thing that you can do is create separate domains that you can make their document roots point to each of the websites folders. Then proxy to one of those domains.
That way the URL on the browser doesn't change domain names, and internally, you're proxying requests back to yourself and the individual website domains will each have their own document root.
I plan to run multiple sites on that server.
I looked arround a bit but only found rather cryptic stuff i can't work with.
So basically all projects reside in their subfolder in /var/www/. Multiple sites go with multiple domains, so what I want to accomplish is this:
http://example.com goes to my xx.xx.xx (serverip) and loads the site in /var/www/example/publicdir/index.php
http://something.else maps to /var/www/something/publicdir/index.php
Is it something that needs to be done in the apache on the server via virtualhosts? I'm completely clueless
Oh yeah I have an extra condition, I dont want 301 Redirects
I hope you can get through my babbling, my head feels like jelly since I'm trying to get it done for a few hours
Look into VirtualHost config. You don't need any mod_rewrite stuff. You can setup multiple domains in same Apache config with one VirtualHost section for each domain.
Basically what you want is to have different Document root for different domains. The example here will help you http://httpd.apache.org/docs/2.2/vhosts/mass.html#xtra-conf
This is my website url http://mywebsite.com
I create an another website but this website's url would be http://mywebsite/mynewwebsite.com
Please help to find the solution using .htaccess file.
That's impossible. You can do http://mywebsite.com/mynewwebsite/ or http://mynewwebsite.mywebsite.com/ but not what you're asking.
Furthermore, I don't think you can set up subdomains simply using htaccess.
Hi are there ways to make the subfolder type like these in a url.http://subfolder.domain.com
http://domain.com/subfolder
http://subfolder.domain.com
Unfortunately it isn't possible with .htaccess alone, you need to fiddle with your web server's config.