By JR
Webmaster
I have 2 domains:
Both domains have the same DocumentRoot setup in VirtualHost:
First looks like:
<VirtualHost *:80>
DocumentRoot /var/www/example-1
ServerName www.example-1.com
ServerAlias example-1.com
</VirtualHost>
Second looks like:
<VirtualHost *:80>
DocumentRoot /var/www/example-1
ServerName www.example-2.com
ServerAlias example-2.com
</VirtualHost>
However, I want the second domain to redirect to a specific file with a special query to display different content. On my local host I have been able to get this setup to work, but I have been unsuccessful at mimicking this on my remote DO Ubuntu server.
I’m currently rewriting using mod rewrite conditioning. This is my local setup:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example-2.com
RewriteRule ^$ page.php?foo=bar[QSA]
</IfModule>
The first domain, example-1.com by default will showcase page.php content without any mod rewrite rules or query needed as I have designed it to do so. The second domain, example-2.com on the other hand will need to show specific content different from what example-1.com shows. Again, this all works locally for me, but when I imitate this all on the remote server I get no dice. Any help would be greatly appreciated, thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Disregard, I came up with an alternative solution which I think is a better one. I’m controlling each requested domain/host from within the scheme of the program, and serving up the content accordingly. :)
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.