Simple redirect; I'm tooo stupid for that ..

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Fri May 01, 2020 8:46 pm    Post subject: Simple redirect; I'm tooo stupid for that .. Reply with quote

Hello there,

I have gave up ... May someone can help?

I just like redirect ...

http(s)://mail.domain.tld?{any parameter}

to

https://domain.tld/mail?{any parameter}

FROM: http or https with any parameter as tail

TO: HTTPS with the parameter from FROM
_________________
DLzG
Micha
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Sun May 03, 2020 1:27 pm    Post subject: Re: Simple redirect; I'm tooo stupid for that .. Reply with quote

M*I*B,

Create a host with HTTP+HTTPS for domain mail.domain.tld .

In that host, create a URL rewriting rule with the following parameters:

Code:
  Type: Global
  Virtual Path regular expression: ^/$
 
  If this rule matches: Perform an external redirection
  Redirect to: https://domain.tld/mail
  Append Query String: checked
  Escape Redirection Location: checked
  Status Code: 302


Press OK twice and restart the server.

The above assumes that only the root of mail.domain.tld will be redirected. But it does not cover URL with a path in them such as http://mail.domain.tld/some/path/to/file.ext . You could probably give us more details about what to do with such paths (redirect or process normally).

Also, should you redirect from mail.domain.tld when there are parameters after ? only or should you always redirect even with empty or no parameters?
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Sun May 03, 2020 2:29 pm    Post subject: Reply with quote

... at 1st ty for the answer ...

Q: That you have explain redirect mail.domain.tld and also all other like domain.tld to domain.tld/mail... Or am i wrong?

I will write is like that:

IF
(http OR https) AND (mail.domain.tld OR mail.domain.tld?*)
THEN
REDIRECT to https://domain.tld?*
ENDIF

In simple words: Redirect ONLY subdomain "mail." to "/mail" with all given parameter, if some.
_________________
DLzG
Micha
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Mon May 04, 2020 5:07 pm    Post subject: Reply with quote

M*I*B wrote:
Q: That you have explain redirect mail.domain.tld and also all other like domain.tld to domain.tld/mail... Or am i wrong?


Aprelium's reply is exactly what you need to do to accomplish your objective.

If you click on Host --> Configure --> General --> Hostnames, you will see which hosts/domains for which the URL rewriting will occur. (This should be mail.domain.tld) If your host is set up to handle HTTP+HTTPS, then the URL rewrite will occur over both protocols.

The part of the URL after the question mark is called the query string. That will be tacked on the URL rewrite by specifying "Append Query String," as Aprelium mentioned.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Mon May 04, 2020 5:46 pm    Post subject: Reply with quote

Ok, I believe that; you know I have no idea about RegEx ^^

I entered the redirect in two different domains exactly as specified above (of course with the correct domain names; of course ...)

domain1 haven't a subdomain "mail".
I call mail.domain1.tld and got an 403

domain 2 have a subdomain "mail"
I call mail.domain2.tld and stay on mail.domain2.tld

In both case the rewriting don't work.

What I'm doing wrong???
_________________
DLzG
Micha
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Tue May 05, 2020 10:33 am    Post subject: Reply with quote

M*I*B,

An URL is made of a schema (http or https), an ip or domain name possibly with a port, a virtual path, and possibly a query string introduced by ? .

The Web server will deal with the schema and the domain name to determine the host that will serve the URL.

At the host level, the virtual path is important and it's what URL rewriting uses to know if a rule should be applied.

So our question was "what to do with the virtual path" of the URLs for domain name mail.domain.tld (whether they come on http or https)?

Regarding the regular expression, it's not very complex. $/^ means match with a virtual path which is exactly equal to / . A quick overview on the syntax of regular expressions is in https://aprelium.com/abyssws/articles/regex-basics.html . We highly recommend checking it as it proves useful for many tasks.

So why it didn't work? Error 403 is probably due to the fact that the redirection goes to a non-handled domain name.

In all cases, we suggest that you contact us by email with your abyss.conf and the exact URLs you have tested and which did not work. A quick review of your configuration will help us determine what went wrong.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Tue Apr 20, 2021 2:22 pm    Post subject: Reply with quote

Ok, back again...

HowTo...

http://domain.com/*
http://www.domain.com/*
https://www.domain.com/*

... all have to redirect to ...

https://domain.com/*


http -> https runs well but I'm not able to implement the //www. to //
_________________
DLzG
Micha
Back to top View user's profile Send private message
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Tue Apr 20, 2021 8:35 pm    Post subject: Reply with quote

Could you not do this for your mail redirect...




and end with this to redirect everything else to https://domain.com/*

Back to top View user's profile Send private message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Tue Apr 20, 2021 8:55 pm    Post subject: Reply with quote

... ahhh, I'm sorry ... I have forget to say that meanwhile the SUB mail stay as it. That's gone...

So...

http://mail.domain.com goes to https://mail.domain.com

... due I have set in /edit/general/advanced/edit "Exclusively Serve On HTTPS" to "*". That's also touch all other url entered as non secure. That haven't to handled by a rule anymore.

So only the given on my question post have to be handled by a rule.

I have try the 2nd rule you write down and it looks like that works fine!
Thank you very much for that!

That works well with all 4 domain:
http://domain1.com
http://domain2.com
http://www.domain1.com
http://www.domain2.com

--> https://domain1.com (have to be ever the target)

What not working is:
https://domain2.com OR https://www.domain2.com will NOT be redirect to https://domain1.com

EDIT say...
I have try some combinations and noticed that I can't get in touch with mail.domain1.com. So I have try the following and it looks like ok... Or I'm wrong?




Final I think that the whole stuff is much more complicated as expected ^^




I will compact my need again (hope now it's complete):

http://domain1.com (works native due Exclusively Serve On HTTPS)
http://domain2.com (works due the rule)
http://www.domain1.com (works due the rule)
http://www.domain2.com (works due the rule)
https://domain2.com (works NOT)
https://www.domain1.com (works NOT)
https://www.domain2.com (works NOT)

... have all to be redirected to https://domain1.com

Except all subdomains with mail.
All mail.domainX.com have to be redirect like this:

http://mail.domain1.com (works native due Exclusively Serve On HTTPS)
http://mail.domain2.com (works NOT; runs in a 403 forbidden / shure... there is no rule yet)
https://mail.domain2.com (works NOT; runs in a 403 forbidden / shure... there is no rule yet)

... have all to be redirected to https://mail.domain1.com


Ok, enough for today... Need a cup of sleep... [/u]
_________________
DLzG
Micha
Back to top View user's profile Send private message
Paulie
-


Joined: 20 Feb 2016
Posts: 24

PostPosted: Wed Apr 21, 2021 5:56 am    Post subject: Reply with quote

Quote:
What not working is:
https://domain2.com OR https://www.domain2.com will NOT be redirect to https://domain1.com


And you have a host set up for both
http+https://domain1.com and http+https://domain2.com
in the Web Server Console?
Back to top View user's profile Send private message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Wed Apr 21, 2021 6:19 am    Post subject: Reply with quote

... yes, definitely ...

Host 1:
* http & https with Option Exclusively Serve On HTTPS
* Point physically to the webside
* Servernames:
domain1.com (https- Master & target for all Host 1 rules)
domain1.eu
domain2.com
domain2.eu
www.domain1.com
www.domein1.eu
www.domain2.com
www.domain2.eu

Host 2:
* http & https with Option Exclusively Serve On HTTPS
* Point physically to the webmailer
* Servernames:
mail.domain1.com (https- Master & target for all Host 2 rules)
mail.domain1.eu
mail.domain2.com
mail.domain2.eu

In my brain there is a ghost that tell me I need a rule that say ...

IF NOT https://domainX.com REDIRECT to https://domainX.com
_________________
DLzG
Micha
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Wed Apr 21, 2021 9:08 pm    Post subject: Reply with quote

Could you please contact our technical support by email to speed up working o a solution?

Please let us know the exact requirements too. :)
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Thu Apr 22, 2021 12:28 pm    Post subject: Reply with quote

... hmmm ...
I believe all the requirement are written down in my last post.

I also like to work/talk with all here on a solution to help others in the future.
That's actually the point of a forum ... isn't it?
What speaks against posting a solution here so that other users can benefit from it? I am pretty sure that I am not the only user who comes across such tasks now and in the future ...
_________________
DLzG
Micha
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Sun Apr 25, 2021 2:31 pm    Post subject: Reply with quote

M*I*B wrote:
... yes, definitely ...

Host 1:
* http & https with Option Exclusively Serve On HTTPS
* Point physically to the webside
* Servernames:
domain1.com (https- Master & target for all Host 1 rules)
domain1.eu
domain2.com
domain2.eu
www.domain1.com
www.domein1.eu
www.domain2.com
www.domain2.eu

Host 2:
* http & https with Option Exclusively Serve On HTTPS
* Point physically to the webmailer
* Servernames:
mail.domain1.com (https- Master & target for all Host 2 rules)
mail.domain1.eu
mail.domain2.com
mail.domain2.eu

In my brain there is a ghost that tell me I need a rule that say ...

IF NOT https://domainX.com REDIRECT to https://domainX.com


Move Host 2 ahead of Host 1.

Quote:
* http & https with Option Exclusively Serve On HTTPS

The above option will take care of the thought below:
Quote:
IF NOT https://domainX.com REDIRECT to https://domainX.com





Are you also saying you want all these domains:

_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Mon Apr 26, 2021 7:39 am    Post subject: Reply with quote

... yes, that's right ...

I see three blocks here.

The 1st one make https if http called via option "Exclusively Serve On HTTPS". I think that this one have the highest priority due it's the 1st touch.

The 2rd one as rule have to redirect all mail.* subs to mail.domain1.com

The 3rd one as rule have to redirect all with and without www.*, except mail, to domain1.com


Can it be better to go an other way?

1. http -> https by "Exclusively Serve On HTTPS"
2. mail.* -> mail.domain1.com
3. www.* -> domain1.com
4. NOT domain1.com -> domain1.com


... ok, now I've confused myself *grrr*


!!! Not that we talk at different things: the whole domain-block for webside is one host, the whole mail.* block for webmail is an other host (on the same machine) !!!


BTW: Over the years I try again and again to understand/learn RegEx but sometimes two things never goes together like RegEx and my Brain...
_________________
DLzG
Micha
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Mon Apr 26, 2021 9:35 pm    Post subject: Reply with quote

M*I*B,

We can simplify the whole setup to:

1. http -> https by "Exclusively Serve On HTTPS"
2. mail.* -> mail.domain1.com
3. anything else -> domain1.com

The problem is that with HTTPS, you cannot use the default host only. You should have host where you declare all possible host names so that the ACME certificate is valid for all of them.

In other words, you'll need host 1 associated with all named variations of mail.* including mail.domain1.com. This host should have a URL rewrite rule to redirect to mail.domain1.com if host name is different from mail.domain1.com.

Host 2 should also be associated with all named variations of all other recognized domain names including www.* and domain1.com. It should also have a URL rewrite rule to redirect to domain1.com if host name is different from domain1.com.

Both hosts should have the "Exclusively Serve On HTTPS" enabled for all their virtual paths (/).
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
M*I*B
-


Joined: 05 Dec 2019
Posts: 33
Location: Germany

PostPosted: Sat May 01, 2021 9:55 pm    Post subject: Reply with quote

admin wrote:
M*I*B,

In other words, you'll need host 1 associated with all named variations of mail.* including mail.domain1.com. This host should have a URL rewrite rule to redirect to mail.domain1.com if host name is different from mail.domain1.com.

Host 2 should also be associated with all named variations of all other recognized domain names including www.* and domain1.com. It should also have a URL rewrite rule to redirect to domain1.com if host name is different from domain1.com.


... that is all given; I have post that some posts before. But I can quote my post here again:

M*I*B wrote:
...
Host 1:
* http & https with Option Exclusively Serve On HTTPS
* Point physically to the webside
* Servernames:
domain1.com (https- Master & target for all Host 1 rules)
domain1.eu
domain2.com
domain2.eu
www.domain1.com
www.domein1.eu
www.domain2.com
www.domain2.eu

Host 2:
* http & https with Option Exclusively Serve On HTTPS
* Point physically to the webmailer
* Servernames:
mail.domain1.com (https- Master & target for all Host 2 rules)
mail.domain1.eu
mail.domain2.com
mail.domain2.eu

...

_________________
DLzG
Micha
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1295

PostPosted: Mon May 03, 2021 6:41 pm    Post subject: Reply with quote

M*I*B,

Can you send us your abyss.conf file for review? At this stage, we cannot see what's wrong with the setup you have described. It may be a little glitch elsewhere so we need to have a look on the whole configuration.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group