Forum Archive - How do you retrieve the current domain URL?

How do you retrieve the current domain URL?
Feb 23, 2013 2:45 pm by popular
Hello, I am having a problem in that I want to redirect some of my pages to their https equivalent based on what domain they are on. So I want all pages involving shop.cart to be redirected say from http://ja.mysite.com/blahblah?shop.cart to https://ja.mysite.com/blahblah?shop.cart but when I try and do this via htaccess or PHP I get the result that the domain is always www. even when it is ja. or fr. etc. I guess this must be down to the CDN but there must be a way of recognising which domain I am currently in? Thank you for your time.
Re: How do you retrieve the current domain URL?
Feb 23, 2013 2:49 pm by Edvard
Hi, You can use %{HTTP:X-GT-Lang} variable to know the selected language in .htaccess file.
Re: How do you retrieve the current domain URL?
Feb 23, 2013 2:57 pm by popular
Hi Edvard, thank you for the reply. I am finding it hard to understand. Could you please show me what I should put in the htaccess to say redirect: http://ja.popularseeds.com/contact-us to https://ja.popularseeds.com/contact-us and for that to be active only for the ja domain?
Re: How do you retrieve the current domain URL?
Feb 23, 2013 3:10 pm by Edvard
It can be something like this: RewriteCond %{HTTP:X-GT-Lang} ^ja$ # if language is ja and RewriteCond %{HTTPS} ^off$ # if protocol is not https RewriteRule ^contact-us$ https://ja.domain.com/contact-us [R=301,L] I'm not sure, but it should be possible to use %{HTTP:X-GT-Lang} in the RewriteRule, something like this RewriteCond %{HTTP:X-GT-Lang} !^$ # if there is selected language and RewriteCond %{HTTPS} ^off$ # if the protocol is not https RewriteRule ^contact-us$ https://%{HTTP:X-GT-Lang}.domain.com/contact-us [R=301,L] It should be also possible to do this: RewriteCond %{HTTP:X-GT-Lang} ^(.+)$ # if there is selected language and RewriteCond %{HTTPS} ^off$ # if the protocol is not https RewriteRule ^contact-us$ https://%1.domain.com/contact-us [R=301,L]
Re: How do you retrieve the current domain URL?
Feb 23, 2013 3:15 pm by popular
Hi Edvard, I'm afraid I'm getting 500 server error with both versions. Is there a better or working way in which I can redirect certain URLs to HTTPS and keep the domain so http://ja.popularseeds.com will redirect to https://ja.popularseeds.com?
Re: How do you retrieve the current domain URL?
Feb 23, 2013 3:18 pm by popular
Hello, The third version is close and redirects from http://ja.popularseeds.com to https://.popularseeds.com/contact-us so it is missing the domain but it is nearly there. Do you know how I can get the domain in there? Thank you for your time.
Re: How do you retrieve the current domain URL?
Feb 23, 2013 3:19 pm by Edvard
I'm not sure about your server specifics and cannot tell exactly how it should be, you will need to play with it little more, but you can do the redirect easily in PHP, you can check the selected language using $_SERVER['HTTP_X_GT_LANG'] variable and make the appropriate redirect using header("Location: $redirect_url"); exit;
Re: How do you retrieve the current domain URL?
Feb 23, 2013 3:24 pm by popular
Hi Edvard, thank you for the help. Is there any way I can hire you for an hour or 2 to complete the necessary redirects?
Re: How do you retrieve the current domain URL?
Feb 23, 2013 3:43 pm by Edvard
You may contact 2glux.com to do the configuration for you. Thanks!
Re: How do you retrieve the current domain URL?
Feb 23, 2013 9:04 pm by popular
Hi Edvard, thank you for that. I will have the SSL wildcard cert installed and then try the redirection stuff again. I will send the details through in the contact form. Regards, Anthony.
Re: How do you retrieve the current domain URL?
Feb 24, 2013 4:32 pm by Edvard
Hi, Please send us the file you got from your provider, so we can install it for you on our side. Thanks!
Re: How do you retrieve the current domain URL?
Feb 24, 2013 7:04 pm by popular
Thanks Edvard, I've just send all the info I have for the certificate through to you via your contact form. Please can you install that in my popularseeds.com enterprise installation. Please email me at [email protected] if there is anything missing.
Re: How do you retrieve the current domain URL?
Feb 24, 2013 7:41 pm by Yana
Hi, Can you please send an email with SSL certificate as an attachment?
Re: How do you retrieve the current domain URL?
Feb 24, 2013 10:01 pm by popular
Hello, I have sent SSL info inside a text file to you. Please let me know if that is insufficient.
Re: How do you retrieve the current domain URL?
Feb 24, 2013 10:07 pm by Yana
Hi, Thank you!

SIMILAR TOPICS

Stop sub domain redirection to main domainApr 12, 2016 7:45 pmReplies: 3Post by: xperthere
Add SSL to my domainAug 24, 2017 1:32 amReplies: 1Post by: dsrougi
Translate to an other domainApr 18, 2017 5:59 amReplies: 1Post by: Pcg
problem with sub domain and sub directory structureDec 8, 2016 9:20 amReplies: 3Post by: dceldran
Redirect sub-domain to new domainAug 16, 2016 7:43 pmReplies: 21Post by: minion

Try GTranslate with a free 15 day trial