Ryan Smith Ryan Smith - 11 months ago 41
PHP Question

URL Rewrite Module messing with $_GET variables

I've established a semi-working .htaccess file which alters this link:


to this:


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


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