Friendly URL does not work with https

Asked

Viewed 893 times

0

I use a .htaccess to use friendly url.

Everything works perfectly.

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

But, when I type some url, which is not exactly the file name or path of the same, it does not work. Page not found

mine .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

Without 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

Some help?

Thank you

2 answers

1

In his you did so:

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

But in your URL there is a bar at the end

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

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

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

The / makes recognize with bar at the end and the ? makes it both optional, staying /?

Another thing, make sure there is no other .htaccess in another folder above or if you no longer have rules in your current one .htaccess, because the rules may conflict.

0

Hello, try to leave your . htaccess this way:

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

Browser other questions tagged

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