linux - 访问要重写的地址时出现错误 403

标签 linux apache mod-rewrite

我有以下重写规则:

RewriteRule ^products/([a-zA-Z]+)$ /project/clients/index.php?database=$1&module=products [L,QSA]

目录结构为:

/var/www/project/clients/index.php

写入地址时“http://host/products/clientA/”被定向到“/project/clients/index.php?database=clientA&module=products”。在我的 PC 中带有 linux (debian) 的虚拟机中工作正常,但服务器 linux 返回 403 错误。

但是如果我改写这个规则:

RewriteRule ^project/products/([a-zA-Z]+)$ /project/clients/index.php?database=$1&module=products [L,QSA]

然后写入url:“http://host/project/products/clientA/”,效果很好

“/var/www/project/”及其子目录的权限适合apache。

谢谢。

编辑 我向“http://serverfault.com”提出问题

initial question

最佳答案

您应该将 .htaccess 文件放在 docroot 目录(public_html 或 htdocs)中。 示例:
网址:http://example.com/somedir/somefile.php
路径:/var/www/example/htdocs/somedir/somefile.php
.htaccess 应放置在 /var/www/example/htdocs/.htaccess 中。

当您收到 HTTP 403(或 500)错误时,您应该首先查看错误日志。

关于linux - 访问要重写的地址时出现错误 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3652598/

相关文章:

linux - apache2 重写规则不起作用

php - .htaccess URL 重写错误 - 在此服务器上找不到请求的 URL

.htaccess - URL/子域重写(htaccess)

c - 使用 xlib 窗口总是在最上面

linux - 在左花括号和右花括号之间获取字符串

java - 我怎样才能在java中实现像apache reload这样的东西?

regex - htaccess 无法正常工作

apache - 向 htaccess 文件添加通配符 IP 范围?

c# - Mono Socket.Bind 在连接之前绑定(bind)以使用特定接口(interface)

linux - 如何从停止的程序中获取核心转储 (linux)