× Here you can get community support related to ReDJ.

redirect subdomains to a url query part

  • darkhoros
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 months ago #5902 by darkhoros
redirect subdomains to a url query part was created by darkhoros
Hi,
I have subdomains as follows,
sub1.mydomain.com
sub2.mydomain.com
sub3.mydomain.com ... etc

Need to redirect each of these to
http://{siteurl}/index.php/component/joomd/real-estate-egypt/search-results?field_29=sub1
http://{siteurl}/index.php/component/joomd/real-estate-egypt/search-results?field_29=sub2
http://{siteurl}/index.php/component/joomd/real-estate-egypt/search-results?field_29=sub3

How can i do this?can't figure out the 'from url' and the placeholders.
Thank you for your support.
Regards.

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #5904 by admin
Replied by admin on topic redirect subdomains to a url query part
Assuming you have Joomla plus ReDJ on each subX domain, and the destination is under www, the rule is the following:
From URL: ^https?://(sub1|sub2|sub3)\.mydomain\.com/?$
To URL: {scheme}://www.mydomain.com/component/joomd/real-estate-egypt/search-results?field_29=${b}
Request only: false (unchecked)

With the following placeholders:
a={host}
b={preg_placeholder 1,a}/^([^\.]+)\./i{/preg_placeholder}

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

  • darkhoros
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 months ago #5905 by darkhoros
Replied by darkhoros on topic redirect subdomains to a url query part
Hi,
From URL: ^https?://(sub1|sub2|sub3)\.mydomain\.com/?$
this assumes I have only 3 subdomains, but I actually have several hundreds, so I need the rule to be dynamic and not limited to only 3 subs, so this part (sub1|sub2|sub3) needs to be more flexible, also I need the from url to support http and https, is that possible.
Thank you for your unmatched support.
Regards.

Please Log in or Create an account to join the conversation.

More
7 years 1 month ago - 7 years 1 month ago #5906 by admin
Replied by admin on topic redirect subdomains to a url query part
The From URL AS-IS already supports both http and https (see s?, means s present or not). To match any possible subdomain you can use a simple .* in the From URL and rely on the Skip field to avoid loops:
From URL: .*
To URL: {scheme}://www.mydomain.com/component/joomd/real-estate-egypt/search-results?field_29=${b}
Request only: false (unchecked)
Skip: ^https?://www\.

Same placeholders:
a={host}
b={preg_placeholder 1,a}/^([^\.]+)\./i{/preg_placeholder}

Kind regards,
Luigi
Last edit: 7 years 1 month ago by admin.

Please Log in or Create an account to join the conversation.

  • darkhoros
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 1 month ago #5907 by darkhoros
Replied by darkhoros on topic redirect subdomains to a url query part
Hi,
The target url is shown correctly on the url bar, but the page is not loading and firefox says
The page isn’t redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept cookies.

Please Log in or Create an account to join the conversation.

More
7 years 1 month ago #5908 by admin
Replied by admin on topic redirect subdomains to a url query part
Try to clear browser cache.

Please Log in or Create an account to join the conversation.

Time to create page: 0.113 seconds