My app is in angular js which is on sub domain like http://app.xyz.com i want to redirect it to https://app.xyz.com here is htaccess which i used to redirect it
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+)\.xyz\.com$
RewriteRule ^(.*)$ https://%1/$1 [L]
When site load first time it's work fine but when i reload then i got page not found error everytime
Thanks
This will redirect all urls to https.Try this
# Redirect all url to https #
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Related
Hi after 1 week of research i'm still stuck with my domain redirections
I want my http://domain.fr pointing to https://www.domain.fr
I'm trying with htaccess file with no success...
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.*
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
When i'm testing my redirections it seems https://www.domain.fr is redirecting itself without understading why...
have you guys any idea ?
The problem is in your 2nd RewriteRule
RewriteCond %{HTTP_HOST} ^www\.*
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
You rule does a permanent redirection of www domain to the same location ie : ( www.e ample.com => www.example.com ) that is why you got the redirect loop error.
To redirect http urls to https ,first of all you need to check if the request scheme is http. You can use RewriteCond %{HTTPS} off to check the non - secure http connection and then use RewriteRule to redirect the request to https .
Use the following simple Rule to redirect http to https :
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
Make sure to clear your browser cache before testing this.
I have the following in my htaccess file which redirects all pages to https
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?confetticostume\.ch
RewriteRule .* - [L]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I'm trying to set up a dev area for testing a new multisite build but when i got to confefttibox.ch/0-NEWSTORE it is changing the url to https and then gives me a 404 error.
How can I change the htaccess rule to allow ALL pages within /0-NEWSTORE to be http?
To allow all pages within /0-NEWSTORE to be https, you need to exclude them from the rule, To exclude pages, put the following condition above your rewriteRule
RewriteCond %{REQUEST_URI} !^/0-NEWSTORE/.+$ [NC]
I'm currently trying to force https for may domain name. Its working for mydomain/wildcard but not for the home url that is mydomain/
I'm using this line for redirection in my .htaccess file:
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
You're almost there, use this in your .htaccess:
RewriteEngine On
#Force HTTPS on everything
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
That will force HTTPs on everything
I have been able to find solutions to each of these redirects separately but I can't find something that does both correctly.
I need the website to redirect from:
http://somesite.com.au to https://somesite.com.au
http://www.somesite.com.au to https://somesite.com.au
https://www.somesite.com.au to https://somesite.com.au
The main combination that I'm having trouble with is:
https://www.somesite.com.au to https://somesite.com.au
Currently I am using the following in my htaccess file:
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Ensure we are using HTTPS version of the site.
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect www to non-ww
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
What should I be using in my htaccess to make this work?
You're causing a loop because your www rule redirects to http://. Just change it to redirect to https:// instead:
# Redirect www to non-ww
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
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]