httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mitchell Krog Photography <mitchellk...@gmail.com>
Subject Re: [users@httpd] Problem with Redirect
Date Sat, 08 Jul 2017 13:50:24 GMT
Hi Blake, worth a shot, try this. I used to do my redirects like this but don't use Apache
anymore but this worked perfect for me.

<VirtualHost *:80>
ServerName abc.com
ServerAlias *.abc.com
ServerAdmin me@xyz.com
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
        RewriteRule (.*) https://def.com/ghi/#about [END,QSA,R=permanent]
</VirtualHost>

or


<VirtualHost *:80>
ServerName abc.com
ServerAlias *.abc.com
ServerAdmin me@xyz.com
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
        RewriteRule (.*) https://def.com%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>



Kind Regards
Mitchell Krog
**************************************************
Visit me at https://mitchellkrog.com
**************************************************


From: Blake McBride <blake1024@gmail.com>
Reply: users@httpd.apache.org <users@httpd.apache.org>
Date: 08 July 2017 at 3:35:00 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Subject:  [users@httpd] Problem with Redirect  

Hello,

I am using Apache 2.4.18 on a 64 bit Linux box.  I am serving several different URL's via
VirtualHost.  All is working well except a single, unique case.   In the case with the problem,
I am attempting to redirect a URL to an external URL.  All the cases that work, I am hosting
the site, but not in this one case.

Naturally, I own the domain name.  The DNS points to my server, but I want it redirected
to a site I pay for but isn't hosted by my machine.  Under /etc/apache2/sites-enabled, I
have:

<VirtualHost *:80>
ServerName abc.com
ServerAlias *.abc.com 
ServerAdmin me@xyz.com
Redirect / https://www.def.com/ghi#about
</VirtualHost>

Let's say the main URL for my machine is jkl.com.  Now, when I go to abc.com it ends up at
jkl.com !!

Whenever I change the apache2 settings, I do:  apache2ctl restart

When, through my browser, I go to abc.com, I see the following under /var/log/other_vhosts_access.log:

jkl.com:80 174.195.128.13 - - [08/Jul/2017:13:31:07 +0000] "GET / HTTP/1.1" 200 2846 "-" "Mozilla/5.0
(X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"

How the heck is access to abc.com showing as jkl.com?  How can I make abc.com redirect to
the external server at URL https://www.def.com/ghi#about ?

Thanks so much for help!

Blake McBride



Mime
View raw message