Write an .htaccess file without %{REQUEST_FILENAME}
So I have a ridiculous problem that the hosting company cannot seem to take care of by itsel开发者_如何学编程f. I have a website on a windows server that has ISAPI Rewrite 3 running to allow me to use .htaccess files for wordpress. But I noticed that the
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
statements are not working. They are just ignored. Is this a configuration issue? In the mean time I have the site up and running with this clever line that I stole from somewhere
RewriteCond %{REQUEST_URI} (/[^.]*|\.(html?|php))$ [NC]
The problem is that using this line I cannot access an actual directory that exists. Ex. /wp-admin/ so if I want to make changes in the admin area I have to enable that line that restricts by IP make the changes and then turn off that line. Utterly ridiculous.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} (/[^.]*|\.(html?|php))$ [NC]
#disallow or allow just my IP address
#RewriteCond %{REMOTE_HOST} !1.2.3.4
RewriteRule .* /index.php [L]
Any solutions so that I can still access directories that exist without using the %{REQUEST_FILENAME}?
Well .. I have Helicon ISAPI_Rewrite v3 running on IIS 6 (and had it on IIS 7 2 years ago) .. and these instructions actually work fine:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
It may not work that well if part of the URL is virtual folder / application .. but it works fine with real files and folders. Try these instead (should work exactly the same if no virtual stuff involved):
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
精彩评论