123-reg subdomain redirect to secure URL - dns

I manage the DNS of a URL through 123-reg. I'm looking to create a subdomain and have it redirect to a specific folder of a secure URL for example https://sub.url.com/folder. How can I do this?

You can do this with some htaccess on the root folder of your domain.
ie:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(sub.)?url.com$
RewriteRule ^(/)?$ FOLDER [L]
Re-reading your question..
if users come on a non secure URL, you can always redirect them first to HTTPS like so
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
then redirect to the subfolder.

Related

Redirect subdomain to https with htaccess

I want to redirect all URLs only from one subdomain to https.
My URL http://nip.domain.com/sitexy.html should be https://nip.domain.com/sitexy.html
With this code I will be redirected to the home page with https and the path will be removed:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(nip)\. [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]
Can anybody give me a hint, how to keep the path behind the domain?
Thanks!

Redirect domain to WWW

I want to make a URL change whenever clients access my website with example.com to wwww.example.com I have used .htaccess for this but it works not correct.
Because now a-z0-9.example.com wil also redirect to www.example.com, I want this only works for example.com than redirect to www.example.com
.HTACCESS
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.eample.com/$1 [L,R=301,NC]
Make another .htaccess for a-z0-9.example.com with the code bellow:
RewriteEngine on
RewriteCond %{HTTP_HOST} a-z0-9.example.com [NC]
RewriteRule ^(.*)$ http://www.a-z0-9.example.com/$1 [L,R=301,NC]
I think this will work.
Good Luck!

htaccess apending parked domains subfolder to the URL

I created a website for a client and as per normal with our sites included an htaccess file to redirect any non-www traffic to the www. subdomain.
The client has now added a parked domain as a subfolder where they want to host another site. If you go to www.parkeddomain.com then it works, displaying the site in the PARKEDDOMAIN.COM subfolder. However if you go to parkeddomain.com then the htaccess redirects you to www.parkeddomain.com/PARKEDDOMAIN.COM. How can I stop it appending the subfolder to the URL?
This is the contents of the htaccess file:
Options +FollowSymLinks
RewriteEngine on
# Redirect old URLs to new URLs
Redirect /jewelry-the-experience /custom-made-jewelry
Redirect /jewelry-the-process /custom-made-jewelry
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*)$ /handle-url.php [L]
Add the following rule just before the existing one.
RewriteCond %{HTTP_HOST} ^parkeddomain\. [NC]
RewriteRule ^(?:parkeddomain\.com/?)?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NC,L]
RewriteCond %{HTTP_HOST} !^(www|parkeddomain)\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
We catch the no-www parked domain first and redirect without its sub-directory. This makes sure the existing rule is always redirecting the primary domain only.

.htaccess redirection to specific url

I moved my site from blog.abc.com to www.abc.com
I want to redirect every request made to blog.abc.com to abc.com
For example:
If blog.abc.com/example.html is requested, it should redirect to www.abc.com/example.html, how can I do it via .htaccess only?
You can put this code in your htaccess (in blog.abc.com root folder)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
Using mod_rewrite you could do it like this:
RewriteEngine On
RewriteCondition %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
or if blog.example.com has its own vhost you could also use mod_alias:
Redirect / http://example.com/

Remove SSL integration from a specific folder using htaccess

I have an integrated SSL for my entire site and have placed htaccess code to redirect to https when anyone visits my domain URL. But I want to keep one folder out of this redirection to https. Please help me with this... Below is the htaccess code placed in my root to redirect all requests to https counterpart
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Thanks
Just add a condition to exclude the folder:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/folder1
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
And if you wanted to redirect SSL requests to non-SSL for /folder1, then:
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/folder1
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Resources