Re: [users@httpd] Apache Rewrite - Redirect Wildcard Subdomain

2016-09-19 Thread Webmaster33
Yes, missing wildcard DNS was one of the problems.
It is fixed now.

But there are still some problems.

Here are the config file I use:
"subdomain.oldsite.com" Apache config file:

ServerName subdomain.oldsite.com
ServerAlias *.subdomain.oldsite.com

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^v3\.subdomain\.oldsite\.com$ [NC]
RewriteRule .* https://v3.subdomain.newsite.com%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^v3\.subdomain\.oldsite\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.+\.)?subdomain\.oldsite\.com$ [NC]
RewriteRule ^/(.*) https://%1subdomain.newsite.com/$1 [R=301,L]



"subdomain.oldsite.com_ssl" Apache config file:

ServerName subdomain.oldsite.com:443
ServerAlias *.subdomain.oldsite.com:443

RewriteCond %{ENV:HTTPS} !On [NC]
RewriteCond %{HTTP_HOST} ^(.+\.)?subdomain.oldsite.com$ [NC]
RewriteRule ^/(.*) https://%1subdomain.newsite.com%{REQUEST_URI} [R=301,L]



Below I list some url rewrite Tests (Note: I always want to redirect
unsecure urls to secure urls).

Some redirection are OK, others are failing:
http://subdomain.oldsite.com/=>https://subdomain.newsite.com/
OK

https://subdomain.oldsite.com/=>https://subdomain.newsite.com/
OK

http://subdomain.oldsite.com/view.php?id=9032=>
https://subdomain.newsite.com/view.php?id=9032
OK

https://subdomain.oldsite.com/view.php?id=9032=>
https://subdomain.newsite.com/view.php?id=9032
OK

http://aaa.subdomain.oldsite.com/=> https://aaa.subdomain.newsite.com/
It works!
This is the default web page for this server.

http://aaa.subdomain.oldsite.com/view.php?id=9032=>
https://aaa.subdomain.newsite.com/view.php?id=9032
The requested URL /view.php was not found on this server.

https://aaa.subdomain.oldsite.com/=>https://aaa.subdomain.oldsite.com/
Your connection is not secure
aaa.subdomain.oldsite.com uses an invalid security certificate. The
certificate is only valid for the following names:
*.subdomain.newsite.com, subdomain.newsite.com Error code:
SSL_ERROR_BAD_CERT_DOMAIN

http://v3.subdomain.oldsite.com/=>https://v3.subdomain.newsite.com/
It works!
This is the default web page for this server.

https://v3.subdomain.oldsite.com/=>https://v3.subdomain.oldsite.com/
v3.subdomain.oldsite.com uses an invalid security certificate. The
certificate is only valid for the following names:
*.subdomain.newsite.com, subdomain.newsite.com Error code:
SSL_ERROR_BAD_CERT_DOMAIN


Any suggestion?



2016-09-15 16:23 GMT+02:00 Rodrigo Cunha :
> about Situation 3
> as you set up your dns?
> the subdomains are directed to the correct server?
> in http://aaa.subdomain.oldsite.com/foo/bar.php dsn is different from
> http://subdomain.oldsite.com/foo/bar.php are different subdomains.
>
> 2016-09-15 10:33 GMT-03:00 Webmaster33 :
>>
>> Using Apache 2.2.22.
>>
>> I have the following SSL certificates:
>>
>>
>> Common Name = subdomain.oldsite.com
>> Subject Alternative Names = subdomain.oldsite.com,
>> *.subdomain.oldsite.com
>>
>> Common Name = subdomain.newsite.com
>> Subject Alternative Names = subdomain.newsite.com,
>> *.subdomain.newsite.com
>>
>>
>> I would like the following rewrite actions:
>> 1) Redirect all unsecure requests to secure site, also requests from
>> old sites to new site
>>
>> http://subdomain.oldsite.com   =>  https://subdomain.newsite.com
>> https://subdomain.oldsite.com   =>  https://subdomain.newsite.com
>>
>> 2) Keep request %{REQUEST_URI} between redirects. Also use wildcard
>> subdomains, and redirect them to secure new site, keeping wildcard
>> subdomain.
>>
>> http://subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> https://subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>>
>> 3) wilcard subdomains, which are NOT ALLOWED should redirected to
>> secure subdomain.newsite.com (aaa, bbb are not allowed)
>>
>> http://aaa.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> https://aaa.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> http://bbb.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> https://bbb.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>>
>> No one is allowed, except those subdomains, which are listed in 4. point.
>>
>> 4) wilcard subdomains, which are ALLOWED should redirected to secure
>> mysite.subdomain.newsite.com Allowed site:
>>
>> http://mysite.subdomain.oldsite.com/foo/bar.php   =>
>> https://mysite.subdomain.newsite.com/foo/bar.php
>> https://mysite.subdomain.oldsite.com/foo/bar.php   =>
>> https://mysite.subdomain.newsite.com/foo/bar.php
>>
>> My problem is, that
>>
>> http://aaa.subdomain.oldsite.com/foo/bar.php
>>
>> shows Server not found error.
>>
>> All the 1), 2) kind of situations are 

Re: [users@httpd] Apache Rewrite - Redirect Wildcard Subdomain

2016-09-15 Thread Konrád Lőrinczi
I think you found the problem.
Likely the wildcard DNS is not set.

I wrote to our system admin to set the DNS.

Thanks for the idea!
Webmaster33

2016.09.15. 16:23 ezt írta ("Rodrigo Cunha" ):

> about Situation 3
> as you set up your dns?
> the subdomains are directed to the correct server?
> in http://aaa.subdomain.oldsite.com/foo/bar.php dsn is different from
> http://subdomain.oldsite.com/foo/bar.php are different subdomains.
>
> 2016-09-15 10:33 GMT-03:00 Webmaster33 :
>
>> Using Apache 2.2.22.
>>
>> I have the following SSL certificates:
>>
>>
>> Common Name = subdomain.oldsite.com
>> Subject Alternative Names = subdomain.oldsite.com, *.
>> subdomain.oldsite.com
>>
>> Common Name = subdomain.newsite.com
>> Subject Alternative Names = subdomain.newsite.com, *.
>> subdomain.newsite.com
>>
>>
>> I would like the following rewrite actions:
>> 1) Redirect all unsecure requests to secure site, also requests from
>> old sites to new site
>>
>> http://subdomain.oldsite.com   =>  https://subdomain.newsite.com
>> https://subdomain.oldsite.com   =>  https://subdomain.newsite.com
>>
>> 2) Keep request %{REQUEST_URI} between redirects. Also use wildcard
>> subdomains, and redirect them to secure new site, keeping wildcard
>> subdomain.
>>
>> http://subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> https://subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>>
>> 3) wilcard subdomains, which are NOT ALLOWED should redirected to
>> secure subdomain.newsite.com (aaa, bbb are not allowed)
>>
>> http://aaa.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> https://aaa.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> http://bbb.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>> https://bbb.subdomain.oldsite.com/foo/bar.php   =>
>> https://subdomain.newsite.com/foo/bar.php
>>
>> No one is allowed, except those subdomains, which are listed in 4. point.
>>
>> 4) wilcard subdomains, which are ALLOWED should redirected to secure
>> mysite.subdomain.newsite.com Allowed site:
>>
>> http://mysite.subdomain.oldsite.com/foo/bar.php   =>
>> https://mysite.subdomain.newsite.com/foo/bar.php
>> https://mysite.subdomain.oldsite.com/foo/bar.php   =>
>> https://mysite.subdomain.newsite.com/foo/bar.php
>>
>> My problem is, that
>>
>> http://aaa.subdomain.oldsite.com/foo/bar.php
>>
>> shows Server not found error.
>>
>> All the 1), 2) kind of situations are redirecting fine. I have
>> problems getting result for 3), 4).
>>
>>
>> I have the following config files in /etc/apache2/sites-available/
>>
>> default
>> default-ssl
>> subdomain.oldsite.com
>> subdomain.oldsite.com_ssl
>> subdomain.newsite.com
>> subdomain.newsite.com_ssl
>> mysite.subdomain.newsite.com_ssl
>>
>>
>>
>> Using VirtualHost config files like this (this is from
>> subdomain.oldsite.com):
>>
>> 
>> ServerName oldsite.com
>> ServerAlias *.oldsite.com
>>
>> RewriteEngine On
>>
>> RewriteCond %{HTTP_HOST} ^(.+\.)?oldsite.com$ [NC]
>> RewriteRule ^/(.*) https://newsite.com/$1 [R=301,L]
>> 
>>
>>
>> How can I reach to get good redirection results for 3), 4) ?
>>
>>
>> Thanks in advance!
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
>> For additional commands, e-mail: users-h...@httpd.apache.org
>>
>>
>
>
> --
> Atenciosamente,
> Rodrigo da Silva Cunha
>
>


Re: [users@httpd] Apache Rewrite - Redirect Wildcard Subdomain

2016-09-15 Thread Rodrigo Cunha
about Situation 3
as you set up your dns?
the subdomains are directed to the correct server?
in http://aaa.subdomain.oldsite.com/foo/bar.php dsn is different from
http://subdomain.oldsite.com/foo/bar.php are different subdomains.

2016-09-15 10:33 GMT-03:00 Webmaster33 :

> Using Apache 2.2.22.
>
> I have the following SSL certificates:
>
>
> Common Name = subdomain.oldsite.com
> Subject Alternative Names = subdomain.oldsite.com, *.
> subdomain.oldsite.com
>
> Common Name = subdomain.newsite.com
> Subject Alternative Names = subdomain.newsite.com, *.
> subdomain.newsite.com
>
>
> I would like the following rewrite actions:
> 1) Redirect all unsecure requests to secure site, also requests from
> old sites to new site
>
> http://subdomain.oldsite.com   =>  https://subdomain.newsite.com
> https://subdomain.oldsite.com   =>  https://subdomain.newsite.com
>
> 2) Keep request %{REQUEST_URI} between redirects. Also use wildcard
> subdomains, and redirect them to secure new site, keeping wildcard
> subdomain.
>
> http://subdomain.oldsite.com/foo/bar.php   =>
> https://subdomain.newsite.com/foo/bar.php
> https://subdomain.oldsite.com/foo/bar.php   =>
> https://subdomain.newsite.com/foo/bar.php
>
> 3) wilcard subdomains, which are NOT ALLOWED should redirected to
> secure subdomain.newsite.com (aaa, bbb are not allowed)
>
> http://aaa.subdomain.oldsite.com/foo/bar.php   =>
> https://subdomain.newsite.com/foo/bar.php
> https://aaa.subdomain.oldsite.com/foo/bar.php   =>
> https://subdomain.newsite.com/foo/bar.php
> http://bbb.subdomain.oldsite.com/foo/bar.php   =>
> https://subdomain.newsite.com/foo/bar.php
> https://bbb.subdomain.oldsite.com/foo/bar.php   =>
> https://subdomain.newsite.com/foo/bar.php
>
> No one is allowed, except those subdomains, which are listed in 4. point.
>
> 4) wilcard subdomains, which are ALLOWED should redirected to secure
> mysite.subdomain.newsite.com Allowed site:
>
> http://mysite.subdomain.oldsite.com/foo/bar.php   =>
> https://mysite.subdomain.newsite.com/foo/bar.php
> https://mysite.subdomain.oldsite.com/foo/bar.php   =>
> https://mysite.subdomain.newsite.com/foo/bar.php
>
> My problem is, that
>
> http://aaa.subdomain.oldsite.com/foo/bar.php
>
> shows Server not found error.
>
> All the 1), 2) kind of situations are redirecting fine. I have
> problems getting result for 3), 4).
>
>
> I have the following config files in /etc/apache2/sites-available/
>
> default
> default-ssl
> subdomain.oldsite.com
> subdomain.oldsite.com_ssl
> subdomain.newsite.com
> subdomain.newsite.com_ssl
> mysite.subdomain.newsite.com_ssl
>
>
>
> Using VirtualHost config files like this (this is from
> subdomain.oldsite.com):
>
> 
> ServerName oldsite.com
> ServerAlias *.oldsite.com
>
> RewriteEngine On
>
> RewriteCond %{HTTP_HOST} ^(.+\.)?oldsite.com$ [NC]
> RewriteRule ^/(.*) https://newsite.com/$1 [R=301,L]
> 
>
>
> How can I reach to get good redirection results for 3), 4) ?
>
>
> Thanks in advance!
>
> -
> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
> For additional commands, e-mail: users-h...@httpd.apache.org
>
>


-- 
Atenciosamente,
Rodrigo da Silva Cunha