使用 htaccess 从子目录访问服务器

发布于 2024-12-17 19:29:48 字数 691 浏览 0 评论 0原文

我正在设置 WordPress 开发环境,并对 DocumentRoot 的目录结构有这样的想法;

.htaccess
tags
  - 2.8
  - 2.9
  - 3.0

我的想法是使用 mod rewrite 在不同的标签目录之间切换,但到目前为止,我还没有成功设置它。这是我到目前为止所拥有的;

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /tags/3.2/index.php [L]

我的 VirtualHost 指令中有以下内容;

AllowOverride all
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
DirectoryIndex index.php

但我得到的只是浏览器中列出的目录以及 apache 日志中的此错误消息;

[Fri Nov 25 18:44:44 2011] [错误] [客户端 127.0.0.1] 客户端被服务器配置拒绝:/opt/local/apache2/htdocs/vhosts/wordpress/.htaccess

I'm setting up a WordPress development environment and have this idea for directory structure of the DocumentRoot;

.htaccess
tags
  - 2.8
  - 2.9
  - 3.0

My idea is to use mod rewrite to switch between the different tag directories, so far though, I have been unsuccesful in setting it up. Here's what I have so far;

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /tags/3.2/index.php [L]

I have the following in my VirtualHost directive;

AllowOverride all
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
DirectoryIndex index.php

But all I get is the directory listing in the browser with this error message in the apache logs;

[Fri Nov 25 18:44:44 2011] [error] [client 127.0.0.1] client denied by server configuration: /opt/local/apache2/htdocs/vhosts/wordpress/.htaccess

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

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

发布评论

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

评论(1

拔了角的鹿 2024-12-24 19:29:48

检查此文件,这是 Apache 表示访问被拒绝的位置:

/opt/local/apache2/htdocs/vhosts/wordpress/.htaccess

如果这是您的 VirtualHost 指令所在的位置,则该文件中还有其他内容禁止访问。另请记住,当您更改实际 Apache 目录中的文件时,最好重新启动 Apache 以确保更改生效。有时配置可以包括适用于所有内容的一般规则等。浏览整个文件并确保没有任何内容与您想要执行的操作相冲突。

例如,当您安装 phpMyAdmin 时,随其安装的默认 .htaccess 文件中有一行内容为 Deny from all。我花了 10 到 15 分钟才弄清楚这个问题。

Check this file, that's where Apache is saying that access is being denied from:

/opt/local/apache2/htdocs/vhosts/wordpress/.htaccess

If that's where your VirtualHost directive is then there is something else in that file that is forbidding access. Also remember that when you change a file in the actual Apache directories, it's a good idea to restart Apache to ensure that the change took affect. Sometimes configurations can include general rules which apply to everything, etc. Browse through the entire file and make sure nothing is conflicting with what you're trying to do.

For example, when you install phpMyAdmin, the default .htaccess file that is installed with it is one line reading Deny from all. Took me a good 10-15 minutes to figure that one out.

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