Mobile app version of vmapp.org
Login or Join
Angie530

: 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

@Angie530

Posted in: #Content #Domains #Xampp

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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Angie530

2 Comments

Sorted by latest first Latest Oldest Best

 

@Angie530

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

10% popularity Vote Up Vote Down


 

@Ogunnowo487

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.)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme