Reputation: 716
I have the following code in my .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)$ /pages.php?link=$1
My understanding is that it should check if the file does not exist, check if the directory does not exist and then perform the rule if those are true. For some reason though it is giving me an error when I go to:
The error message that pops up is:
script 'C:/xampp/htdocs/1.php' not found or unable to stat
Strangely though, when I go to: http://localhost/1
it acts as it should (redirects accordingly).
Upvotes: 0
Views: 2746
Reputation: 24448
I believe your problem is your regex. You are using the \w
to match a word. Well .
is not matched in that. Change your rule to this.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /pages.php?link=$1
Upvotes: 5