Error redirecting to https UOL Host

Asked

Viewed 408 times

-2

I have a website hosted on UOL HOST.

I’m setting up a .htaccess in the hope that 2 things will happen:

A) All access by http be converted to httpS

B) Any and all access (Links existing and NON-EXISTENT), are redirected to the index php.

I’m doing it this way:

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteRule ^(.*)$ index.php?page=$1 [NC]

Well, the redirecting to the index is perfect!

But when I try to http for https, although it is enabled https and the file can be accessed directly case that directive NAY is in the .htaccess gives information that

Esta página não está funcionando

But the page only has the HOME text on it and nothing else

1 answer

1

For those interested can. For me this solution worked in parts.

# Redirecionar para HTTPS WC
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Páginas e diretórios com erros de acesso ou código
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php


# Reenvia todas páginas e diretórios ENCONTRADOS para o index
RewriteCond %{SCRIPT_FILENAME} -f
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^(.*)$ index.php?page=$1 [NC]

But there are still two doubts:

A) Necessary to do the <IfModule mod_rewrite.c> at first? Why?

B) Because, although in case I speak httpS to a file, the httpS opens correctly, but redirect does not occur if you access the same link with http instead of httpS,

Note: This only happens in LOCALHOST. On the internet works normally!

One thing I realized is that if I change in httpd.conf the directive

AllowOverride None

for

AllowOverride All

Though I open one empty file, it will already open with erro 500

That is, it seems that the Apache is not accepting permission from .htaccess

Browser other questions tagged

You are not signed in. Login or sign up in order to post.