Reputation: 81
I've established a semi-working .htaccess file which alters this link:
localhost/profile.php?id=6
to this:
localhost/profile/6
However, this is adding .php to the end of my $_GET variables. I'm not very familiar with rewrite modules, .htaccess etc but this is very annoying. Couldn't find anything on the internet about it, if there is a different way to do it or fix it I would greatly appreciate any input.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/(.*) profile.php?id=$1
</IfModule>
Upvotes: 1
Views: 49
Reputation: 18995
Try restricting to only numbers:
RewriteRule ^profile/(\d*) profile.php?id=$1
Or exclude .
, if the ID is not certainly numeric:
RewriteRule ^profile/([^.]*) profile.php?id=$1
Upvotes: 1