user3737317 user3737317 - 2 years ago 94
PHP Question

Can not get variable from .htaccess generated url

I'm trying to get new url using

file but I can't get php variablee name from the url.
.htaccess code is here

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^courses/([a-zA-Z0-9\-\_]+)/$ courses.php?cat-name=$1

php code is

echo $_GET['cat-name'];

But showing error undefined index cat-name. my url is
. So how can I access the php variable?

Answer Source

Looks like you victim of MultiViews options here. Disable it by using:

Options -MultiViews
  • Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download