Friendly URL does not work with https

0

I use .htaccess to use friendly urls.

Everything works perfectly.

But, I installed an SSL certificate in my domain, it is also working, the whole site.

But when I type some url, other than the file name or path, it does not work. Page not found

My .htaccess :

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?dominio.com.br [NC]
RewriteRule ^news/([a-zA-Z0-9_-]+)$ index.php?secao=news&url=$1

With HTTPS:

https://www.dominio.com.br/index.php -> Funciona
https://www.dominio.com.br/news.php -> Funciona
https://www.dominio.com.br/news/alguma-noticia-lala/ -> Não Funciona

No HTTPS:

http://www.dominio.com.br/index.php -> Funciona
http://www.dominio.com.br/news.php -> Funciona
http://www.dominio.com.br/news/alguma-noticia-lala/ -> Funciona

Any help?

Thank you

    
asked by anonymous 13.07.2016 / 11:29

3 answers

1

In your you did so:

^news/([a-zA-Z0-9_-]+)$ 

But your URL has a slash at the end

https://www.dominio.com.br/news/alguma-noticia-lala/

The regex should be like ^news/([a-zA-Z0-9_-]+)/?$ , eg:

RewriteRule ^news/([a-zA-Z0-9_-]+)/?$ index.php?secao=news&url=$1

The / makes it recognize with the slash at the end and the ? makes it optional at the same time, getting /?

Another thing, make sure you do not have any other .htaccess in another folder above or if you do not have any more rules in your current .htaccess , as the rules can conflict.

    
10.01.2018 / 21:44
0

Hello, try leaving your .htaccess like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^news/([a-zA-Z0-9_-]+)$ index.php?secao=news&url=$1
    
13.07.2016 / 13:52
-3

You need to add a rule to redirect all URLs http:// to https:// , otherwise it will not work at all.

You can also search Apache's mod_ssl documentation for more details.

Keep your redirect rules before the routing rules within the domain, so keeping my answer: redirect your http:// to https:// .

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.dominio.com.br/$1 [R=301,L,NE]
    
06.08.2017 / 21:13