I am running static HTML files on a local MAMP server and I would like to pass an ID to a page (user.html) in the 'URL Path' format. Here's what I need it to look like:
This is what my .htaccess file looks like:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
Currently the URL looks like this:
So I could send parameters as Query strings using ?id=
but I need to use the Path format
What is the change I need to make to create that URL Format?
You need add new rewrite rules to pass additional parameters to your pages:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/?$ $1.html [L]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ $1.html?id=$1&name=$3 [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/?$ $1.html?id=$1 [L,QSA]