Josh Josh - 4 years ago 120
PHP Question

How would I go about masking specific $_GET variables as subfolders?

Say for example I have this:

How could I make that look like
using .htaccess while maintaining functionality of the

Answer Source

You can use $_SERVER['REQUEST_URI'], which would contain /admin/system/ in your example. Now you can use the usual string manipulation functions to get the values.

$vars = explode("/", $_SERVER['REQUEST_URI']);
$page = $vars[1];
$setting = $vars[2];

To redirect all requests for inexistant files/directories to your index.php, use this in your .htaccess-file:

RewriteEngine on                     # Activates the rewrite engine
RewriteCond %{REQUEST_FILENAME} !-d  # do not rewrite if folder exists
RewriteCond %{REQUEST_FILENAME} !-f  # do not rewrite if file exists
RewriteRule . index.php [L]          # otherwise, rewrite to index.php
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download