I'm trying to get a virtual directory or file to be passed back to index.php
Example, I want everything after the / to get passed back to index, which will then be checked against a database, but "virtual_directory" and "virtual_file.jpg" don't actually exist, they are just parameters.
somedomain.com/virtual_directory
somedomain.com/virtual_file.jpg
Now, the problem is that EVERYTHING passes. So say I just want to go to the main directory (or just index.php) I would type in the url (somedomain.com) and it would pass the trailing slash as a parameter. It is also the same if I try to go to somedomain.com/index.php. It will pass with /index.php (ie: I cannot get to the else statement).
Is there a way to make it so it will not pass if I am directly going to the index?
These two will pass as a parameter, and I do not want them too.
somedomain.com/
somedomain.com/index.php
.htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]
index.php will read what was after the '/' and do something with it.
if ($_SERVER['REQUEST_URI']) {
echo nl2br("Parameter Passed!\n");
echo 'Parameter That Passed:' .$_SERVER['REQUEST_URI'];
} else{
echo 'No Parameter Passed';
echo 'You Are Visiting domain.com/ or domain.com/index.php';
}