I have the following htaccess file:
RewriteEngine On
RewriteRule ^uploads/(.*)$ https://testcontainer2.venta.one/uploads/$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Has anyone an idea, why my rewrite is not working?
Even the Debugger from https://htaccess.madewithlove.be says, that my rule would apply.
Related
I have an SSL certificate for website http://xyz.co/.
I created .htacces file for forcing users to use https instead of http.
I tried:-
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But it shows me error as
net::ERR_TOO_MANY_REDIRECTS
Try to redirect to an entirely different url to make sure your condition is actually firing. At first sight I would say your RewriteRule is wrong because that's no RegEx, ^ is just an anchor.
So try this:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I assume you don't get ERR_TOO_MANY_REDIRECTS errors when you remove this part.
I am using this code for SSL migration:
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The problem that I am facing is that it is working is that the redirection is not working for most of the folders and URLs but in a few cases it is working and that is what is baffling me.
If the code was correct, it should work for every URL on the site instead of a few or it shouldn't work at all. When I remove the first re-write condition in the .htaccess, the site works just fine.
This is the error that I am getting:
https/www.mysite.com:443/some-folder/xyz.html
Can anybody help?
Thanks in advance.
try this...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
So, I use a chat script called AJAX-Chat
it works fine, but only when I take away the part of my .htaccess file that makes my site always go to https://
I need a way for a SPECIFIC directory to not be https://
My .htaccess code:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Add this above your other rules:
RewriteRule ^(Directory_to_exclude)($|/) - [L]
it will exclude that directory from forced to HTTPS.
Alternate(ther are lots)
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !exclude_me [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I have this setting for my website for SEO-friendly URL, it's working correct. But when I need set some 301 Redirect it works poorly. When I type in address bar that rule below Redirect 301 /example1 /example2 I get www.domain.com/example2?page=example1. How can I change it?
RewriteEngine on
RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Redirect 301 /example1 /example2
You should keep using mod_rewrite since you're already using it. And put the rule above the other one.
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^example/? /example2 [L,R=301]
#redirect to index.php except for example2
RewriteCond %{REQUEST_URI} !^/example2
RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L]
I'm using the following .htaccess file to force any page request to https://
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
How could I force https for all directories/pages except the directory "/domain" ?
I can change the main htacces or create a new one in the /domain directory, the easy way, but how?
This should get what you need.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !domain [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]