Reecrever url with htaccess

1

For lack of experience, I'm having difficulty rewriting the url of my blog, I tried as below:

http://www.meusite.com/blog/article.php?a=3&v=5&at=teste-do-primeiro-post

In the end I would like the result below:

http://www.meusite.com/blog/article/teste-do-primeiro-post

I put .htaccess in the root and then inside the blog folder, what folder does .htaccess have to be?

My last attempt below:

RewriteEngine on

RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+) article.php?a=$1&v=$1&at=$1 [NC,L]
    
asked by anonymous 20.06.2018 / 18:37

1 answer

0

The problem is in regular expression!

For example, you are getting numbers with ER ([0-9]+) in the place where teste-do-primeiro-post would come, which is a string.

In general, without restriction other than / , you can try the below (I put another variable at2 in addition to yours that gets the rest of the URL - until the end):

RewriteRule ^([^\/]*)\/?([^\/]*)\/?([^\/]*)\/?(.*)$ article.php?a=$1&v=$2&at=$3&at2=$4 [L,QSA]
    
20.06.2018 / 19:02