需要使用httpd.conf代替.htaccess进行重写

发布于 2024-08-28 12:44:20 字数 355 浏览 5 评论 0原文

我正在使用一台阻止使用 .htaccess 文件的主机,因此我无法使用它更改我的永久链接。我需要弄清楚要使用什么代码以及将其放在 httpd.conf 文件中的何处才能获得相同的效果。

.htaccess 文件中的代码如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

I am working on a host that blocks my .htaccess file from being used so I can not change my permalinks using it. I need to figure out what code to use and where to put it in my httpd.conf file to get the same effect.

The code in the .htaccess file is below:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

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

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

发布评论

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

评论(2

心病无药医 2024-09-04 12:44:20

您需要将该代码包装在中指示。它的去向取决于您的 http.conf 文件中的其他内容。有关详细信息,请参阅 Apache 文档

然而,正如傻瓜所说;如果您的主机不允许您使用 .htaccess 文件,那么您几乎没有机会被允许靠近 httpd.conf 文件。

You'll need to wrap that code in a <Directory> directive. Where it goes will depend on what else you've got in your http.conf file. See the Apache docs for more info.

However, as blockhead says; if your host won't let you use .htaccess files, you've got virtually no chance of being allowed near the httpd.conf file.

不必了 2024-09-04 12:44:20

例如,如果您想在整个服务器(可能由数百个虚拟主机组成)中阻止对 GoogleBot 的访问,您可以将其添加到您的 httpd.conf 文件中:

#setup the root dir
<Directory />
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} Googlebot
    RewriteRule .* - [F,L]
</Directory>

这将向任何访问者发送 HTTP 403 Forbidden与 Googlebot 一起出现在其用户代理字符串中。通过将其应用于“/”文件夹,此重写条件将应用于所有虚拟主机。

For example, if you'd like to block access to GoogleBot throughout your entire server (which may be comprised of hundreds of virtual hosts), you can add this to your httpd.conf file:

#setup the root dir
<Directory />
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} Googlebot
    RewriteRule .* - [F,L]
</Directory>

This will send a HTTP 403 Forbidden to anyone who comes in with Googlebot in their user agent string. And this rewrite condition will be applied to ALL virtual hosts, by virtue of applying this to the "/" folder.

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