.Htaccess does not allow me to use / in friendly URL

1

In my .htaccess I have the following:

RewriteRule ^topic=([0-9]+)\+autor=([-0-9a-zA-Z/%&]+)\+titulo=(.*)$ /post.php?topic=$1&autor=$2&titulo=$3 [L]

which allows me to use a url of this type:

http://localhost/topic=8+autor=JhonDoe+titulo=Este-post-es-solo-prueba

The problem is that I would like to replace the = and the + of the .htaccess with /

There should be something like that, if I'm not mistaken:

RewriteRule ^topic/([0-9]+)\/autor=([-0-9a-zA-Z/%&]+)\/titulo=(.*)$ /post.php?topic=$1&autor=$2&titulo=$3 [L]

to allow me to use a url like this:

http://localhost/topic/8/autor/JhonDoe/titulo/Este-post-es-solo-prueba

but for some reason I get an error. What am I doing wrong?

    
asked by Jean 09.01.2017 в 02:01
source

1 answer

1

You are correct. I just need to finish replacing all the characters:

RewriteRule ^topic/([0-9]+)\/autor=([-0-9a-zA-Z/%&]+)\/titulo=(.*)$ /post.php?topic=$1&autor=$2&titulo=$3 [L]
                           ^      ^                  ^       ^
  • Fataba replace 2 =
  • Although \/ is valid, I marked it because it is not necessary (it is only necessary to escape the bars in regex engines that use them as delimiters)

It would stay:

RewriteRule ^topic/([0-9]+)/autor/([-0-9a-zA-Z/%&]+)/titulo/(.*)$ /post.php?topic=$1&autor=$2&titulo=$3 [L]
    
answered by 09.01.2017 / 02:18
source