写入不带 %{REQUEST_FILENAME} 的 .htaccess 文件

发布于 2024-11-27 15:17:31 字数 733 浏览 1 评论 0原文

所以我有一个荒谬的问题,托管公司似乎无法自行解决。我在 Windows 服务器上有一个网站,运行 ISAPI Rewrite 3,允许我使用 WordPress 的 .htaccess 文件。但我注意到这些

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

声明不起作用。他们只是被忽视了。这是配置问题吗?与此同时,我使用从某处偷来的这条巧妙的线路启动并运行了该站点。

RewriteCond %{REQUEST_URI} (/[^.]*|\.(html?|php))$  [NC]

问题是使用这条线路我无法访问存在的实际目录。前任。 /wp-admin/ 因此,如果我想在管理区域中进行更改,我必须启用受 IP 限制的线路进行更改,然后关闭该线路。太荒谬了。

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]

有什么解决方案可以让我在不使用 %{REQUEST_FILENAME} 的情况下仍然可以访问存在的目录吗?

So I have a ridiculous problem that the hosting company cannot seem to take care of by itself. 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}?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一百个冬季 2024-12-04 15:17:31

嗯..我在 IIS 6 上运行 Helicon ISAPI_Rewrite v3(两年前在 IIS 7 上运行过它)..这些说明实际上工作正常

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

如果 URL 的一部分,它可能无法正常工作是虚拟文件夹/应用程序..但它可以很好地处理真实的文件和文件夹。尝试这些(如果不涉及虚拟内容,应该工作完全相同):

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文