: Trying to have multiple domains, connect to a same XAMPP server but with different websites I have 2 domains each going to the same IP address. Would it be possible to have the website recognise
I have 2 domains each going to the same IP address. Would it be possible to have the website recognise which domain is connecting to it and show a certain page accordingly?
It is only a small personal server, xampp is being used
More posts by @Angie530
2 Comments
Sorted by latest first Latest Oldest Best
Virtual Hosts:
<VirtualHost *>
ServerAdmin admin@localhost.com
DocumentRoot "C:/xampp/htdocs" # change this line with your htdocs folder
ServerName localhost
ServerAlias localhost
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Thanks for all the help though
Yes, you can do this. Assuming you are using Apache then you can do something like the following using mod_rewrite in either the server config or per-directory .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} =www.example.com [NC]
RewriteRule ^/?foo$ /bar [R=302,L]
This will redirect www.example.com/foo to www.example.com/bar, but it will not do anything with the other domain.
The HTTP_HOST server variable holds the name of the host through which the site has been accessed.
Note also that this is 302 (temporary) redirect. (Temporary redirects should not be cached by the browser so can make testing easier.)
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.