【发布时间】:2013-08-12 21:33:14
【问题描述】:
我有一些域名,例如http://domain.com
http://domain.com/sport -> Folder actually exits
http://domain.com/sport/123/ - > Folder dont exist
http://domain.com/sport/123/hello.html - > file dont exist
所以当http://domain.com/sport/123/ 或
http://domain.com/sport/123/hello.html 被访问了。它必须显示第一个文件夹 index.php 的内容,而不是抛出 not found 错误,即在此示例中它必须显示 http://domain.com/sport/index.php 的内容
我尝试了下面的代码。但它会引发 500 内部错误
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/.*$ /$1/index.php [L]
【问题讨论】:
-
查看您的 Apache 错误日志,了解 500 错误的原因。我在那个 .htaccess 代码中看不到任何语法上无效的内容。
-
我正在通过 cpanel 做...你能告诉我如何检查 apache 错误吗?
-
不,我不能。我不知道 cpanel 如何提供日志访问;您必须检查主机的文档。
-
您可以将
/$1/index.php中的前导/删除为$1/index.php -
@MichaelBerkowski : 没有不工作的先生