On 12/15/2016 10:19 AM, John Williams wrote: > I need to redirect the contents of a URL site from (say) zzz.com to > (say) yyy.com/somepage.html. I need to have port 80 and port 443 > redirected. So the requirement is: > > http://zzz.com/ redirect to http://yyy.com/somepage.html:25999 > AND > https://zzz.com/ <http://zzz.com/> redirect to > https://yyy.com/somepage.html:25999 > > > Will the following rule work? > > <VirtualHost *:80> > ServerName zzz.com > DocumentRoot /var/www/html/zzz > ServerAdmin webmaster@xxxxxxx > ServerAlias www.zzz.com > RewriteEngine On > RewriteRule ^/$ http://yyy/somepage.html [R=301,NC,L] This redirects *only* the URL "/". That is, it will redirect http://zzz.com/ but will not redirect http://zzz.com/something > ErrorLog /var/log/httpd/zzz.error.log > </VirtualHost> > > I tested it for port 80 redirection. That worked fine. Will that also > work for SSL? No, it will not. For that, you'll need to put that rule also in the https vhost. > Also, what does the *[R=301,NC,L]* imply? That is a > googled rule and I don't quite know what it does. R=301 means Redirect, status=301 NC means "case insensitive", which is nonsense in this particular context. L means Last - Do it now. Which is unnecessary in this particular context, unless you have other rewrite rules following. Note also that the Redirect directive does what you're trying to do here without all the song and dance of mod_rewrite Further reading: http://httpd.apache.org/docs/current/rewrite/flags.html http://httpd.apache.org/docs/current/mod/mod_alias.html#redirect http://httpd.apache.org/docs/current/rewrite/remapping.html#canonicalhost -- Rich Bowen - rbowen@xxxxxxxxxxx - @rbowen http://apachecon.com/ - @apachecon
Attachment:
signature.asc
Description: OpenPGP digital signature