Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: [Solved] Redirect only vhost |
|
Author |
|
gijs
Joined: 27 Apr 2012 Posts: 189 Location: The Netherlands
|
Posted: Sun 31 Jul '16 14:52 Post subject: [Solved] Redirect only vhost |
|
|
I have one domain that only needs to do a 301 redirect to a different domain.
Code: |
RewriteEngine On
rewritecond %{http_host} ^domain.com
rewriteRule ^(.*) https://www.domain.net/$1 [R=301,L]
|
I put this code in a .htaccess but it doesn't work, I also added it to the vhost for domain.com but still it doesn't work.
When I visit domain.com I get a 404 error, when I create a index.html it loads that. No redirect
I'm not quite sure what I can do to fix this?
Update: This works
Code: | RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.:]+.)*domain.com.?(:[0-9]*)?$ [NC]
RewriteRule ^/(.*)$ https://www.domain.net/$1 [R=301,L] |
|
|
Back to top |
|
|
|
|
|
|