I'm trying to create clean/pretty URL for a website project such that .php
extensions will be hidden and I'll be able to convert a URL like
example.com/user.php?profile=john-doe
to
example.com/user/john-doe
this is the code I was able to come up with:
RewriteEngine On
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
RewriteRule .* - [L,R=404]
# NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this:
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
#setting query for querying pages
RewriteRule ^(.*?)/(.*?)/?$ $1?name=$2 [NC]
but it us not working, I'll be grateful if I can get this fixed or a better complete .htaccess
configuration to achieve my aim.