Problem with (.) in friendly url

3

I have a website where I show a catalog of products, which with the famous friendly url, transforms said url.

I have:

www.miweb.com/productos/Plancha-para-ropa-nghkdk23

And redirect to:

www.miweb.com/productos/productos.php?idproductos=302

My problem is when I try to see or follow the link of a product whose description has a period ( . ). Example:

www.miweb.com/productos/Telefono-android-5.0

Following the link, it gives me an error, but if I do this (I replace the . with a - ) it works for me:

www.miweb.com/productos/Telefono-android-5-0

The issue is that I do not know how to modify the .htaccess so that the dot sign ( . ) replaces it with a hyphen ( - )

Here is my current code:

RewriteRule ^prod/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ producto.php?id=$1 [NC,L]
    
asked by Maykol Rivas 02.11.2016 в 14:45
source

1 answer

2

Although the redirection that is being made is not clear, since an example is shown and then a rule that does not match the example is shown, the answer is simple.

To accept points in the ID:

The point must be added within the allowed characters:

RewriteRule ^prod/([-.A-Za-z0-9]+)/([-.A-Za-z0-9]+)/?$ producto.php?id=$1 [NC,L]

To replace points with hyphens:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^prod/([^./]*)\.(.*)$ /prod/$1-$2 [NC,L]

RewriteRule ^prod/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ producto.php?id=$1 [NC,L]
    
answered by 02.11.2016 / 14:57
source