Reputation: 183
I'm using URL Rewriting for a simple note application in my website. All things are UNDER /notes/
directory. .htaccess
contents are,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L]
and the url which is to be accessed is,
http://localhost/notes/test.txt
I want to get test.txt as the filename
variable's value.
But when I use echo $_GET['filename'];
in index.php
, it displays index.php
instead of displaying test.txt
.
here, test.txt
is not a real text file but the filename
variable's value.
Upvotes: 0
Views: 66
Reputation: 4022
I think the problem is that your "index.php?filename=test.txt" URL is also being processed and rewritten by your rule. You might need to change your .htaccess
code to stop references to files that exist being rewritten:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L]
Upvotes: 2