Reputation: 57926
I have a site that makes use of GET variables to determine what to display.
@session_start();
@extract($_GET);
@extract($_POST);
.
.
.
if (!$menu) { include("home.php"); }
if ($menu=='buy') { include("buy.php"); }
if ($menu=='invalidbuy') { include("invalidbuy.php"); }
if ($menu=='buydone') { include("buydone.php"); }
.
.
.
I think I have to make use of the .htaccess file to rename my URLs from "/index.php?menu=faq" to "/faq". How can I do this??
Upvotes: 0
Views: 93
Reputation: 655269
You can use the following rule to rewrite any request of a path like /
foobar
internally to /index.php?menu=
foobar
:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/]+$ index.php?menu=$1 [L]
The additional RewriteCond
directive ensures that only non existing files (!-f
) are rewritten.
Upvotes: 1