Redirecionamento HTTPS, excluir parâmetros de script da URL [closed]

2

Meus objetivos:

1. http://example.com/page/index.php -> https://example.com/page/
2. http://example.com/page/ -> https://example.com/page/
3. http://www.example.com/page/ -> https://example.com/page/
4. Any nonexistent file or directory requests -> index.php?&q=$1 for further processing.

As regras a seguir funcionam bem, mas depois de um redirecionamento em um URL do navegador, em vez de um URL limpo

https://example.com/page/

eu vejo

https://example.com/index.php?&q=page/

Como ocultar index.php? & q = page e mostrar https://example.com/page/ no URL? Antes de adicionar o redirecionamento HTTPS, ele funcionava bem para HTTP. Eu tentei 2 soluções com o mesmo resultado.

RewriteEngine on
RewriteBase /

#1 solution:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ [NC]
RewriteRule ^index\.php$ https://%{HTTP_HOST}/ [L,NE,R=301]

RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,NE,R=301]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?&q=$1 [QSA]


#2 solution:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ [NC]
RewriteRule ^index\.php$ https://%{HTTP_HOST}/ [L,NE,R=301]

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,NE,R=301]

RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?&q=$1 [QSA]
    
por Yury Osipenko 19.07.2018 / 23:53

0 respostas