1

我正在一个团队中工作,该团队允许我有限地访问服务器(长篇大论)。我的任务是让 .htaccess 重写子目录 (http://www.myserver.com/subdirectory) 中的 URL。这应该没什么大不了的,除了规则似乎正在重写所有 URL,而不仅仅是那些匹配模式的 URL。

RewriteRule ^products/([^/]*)\.html$ products.php?pr_category=$1 [L]
RewriteRule ^products/([^/]*)/([^/]*)\.html$ products.php?pr_category=$1&pr_subcategory=$2 [L]
RewriteRule ^products/([^/]*)/([^/]*)/([^/]*)\.html$ products.php?pr_category=$1&pr_subcategory=$2&pr_name=$3 [L]
RewriteRule ^tech_resource/([^/]*)\.html$ tech_resource.php?tr_category=$1 [L]
RewriteRule ^tech_resource/([^/]*)/([^/]*)\.html$ tech_resource.php?tr_category=$1&tr_name=$2 [L]
RewriteRule ^news/([^/]*)\.html$ news.php?ne_name=$1 [L]

一切似乎都很好,除了所有页面 URL 都像这样重写:

http://www.mydomain.com/subdirectory/products/category/subcateogry/images/image.jpg

也就是说,重写是将 $1、$2 和 $3 的内容插入到每个 url 路径中。这些应该只是:

http://www.mydomain.com/subdirectory/images/image.jpg

我错过了什么?它可能是根 .htaccess 中的东西吗?

4

0 回答 0