logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: [Solved] Redirect only vhost
Author
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Sun 31 Jul '16 14:52    Post subject: [Solved] Redirect only vhost Reply with quote

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 Neutral

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


Reply to topic   Topic: [Solved] Redirect only vhost View previous topic :: View next topic
Post new topic   Forum Index -> Apache