My url is http://localhost/store/product-detail.php?p=prod%name%test
i want it to look like this
http://localhost/store/prod-name-test
or something like this as other stores do http://localhost/store/p/prod-name-test
I tried so many codes on .htaccess none of them worked. This is my current code
# mod_rewrite starts here
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule \//product-detail.php\s(.*) http://localhost/store/p/?p=Dress$1 [R=301,L]
#RewriteRule ^users/(\d+)*$ ./product-detail.php?p=$1
#RewriteRule ^?([a-zA-Z0-9=_-]+)$ product-detail.php?$1 [NC,L]
#Options +FollowSymLinks
#RewriteRule ^/?$ /product-detail.php [QSA,L]
I tried also window.history.pushState("", "", "/p/<?php echo $prod_name; ?>");
.
It doesn't work.
The most important thing is that the link should respect the SEO. I should also be able to use the request method ?p=
even if its hidden.
.htaccess
can't modify the links in your HTML pages. I'm not sure if that is what you mean by "link should respect the SEO", but if so, you need to find another solution for that part.?p=prod%name%test
" - You've used unencoded%
in your actual URL - is this intentional? (So this would also require conversion to-
in your "desired" URL format?)