Ryan Smith Ryan Smith - 1 year ago 71
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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download