【发布时间】:2015-02-22 08:26:57
【问题描述】:
我尝试设置的网站有这样的结构
website.com
---category1
------subcategory1
------subcategory2
------subcategory3
------subcategory4
---category2
------subcategory1
------subcategory2
------subcategory3
------subcategory4
---category3
------subcategory1
------subcategory2
------subcategory3
------subcategory4
---category4
------subcategory1
------subcategory2
------subcategory3
------subcategory4
当我访问 example.com 时,它会按预期显示所有 4 个类别。 当我选择任何类别时 - 页面被重定向到 example.com/shop/index.php/index.php/index.php... apache文档根文件夹是/var/www/html/shop
但是,当我明确转到 example.com/categoryN 页面时,确实会出现。 子类别也有同样的问题。
这是 .htaccess 文件
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteBase / //I put # in front of it, got no change
writeRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
我怎样才能让这件事发挥作用? 谢谢。
【问题讨论】:
-
所以你有
/var/www/html/shop/index.php?我很确定问题是您有RewriteCond %{REQUEST_URI} !^/index\.php,它表示如果uri 不以index.php 开头,请添加它。如果它不以 index.php!/index\.php$结尾,您可能想要的地方 -
@chris85,是的,有 /var/www/html/shop/index.php 文件。我尝试用
!/index\.php$替换该条件,但仍然出现相同的错误。 -
我将您的代码复制到了我的服务器上,但没有遇到我认为您会遇到的问题。我删除了`//我把#放在它前面,没有变化`并在
writeRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]中添加了re。之后按预期工作,那是你的整个文件吗?我在里面有/public_html/sfo和index.php和.htaccess然后/public_html/sfo/abc/和index.php。这是你的结构吗? -
@chris85,CMS 是 joomla,所以网站结构不等于文件系统之一。 .htaccess 只有一个我没有显示的字符串:
Options +FollowSymLinks。这是服务器 128.199.38.61 的 ip,使其更直观。 -
我无法始终如一地重现它。例如,这个执行路径工作了一次,然后为我循环,然后第三次工作。 128.199.38.61 -> 128.199.38.61/kuhni -> 128.199.38.61/kuhni/kuhnya1
标签: php apache .htaccess joomla system-administration