RewriteCond%{REQUEST_FILENAME}!-d无效

时间:2015-09-17 06:34:15

标签: .htaccess

我已经看过其他几个关于此问题的线索,但由于某些原因,在我的具体情况下,解决方案无效。

这是.htaccess

DirectoryIndex index.php index.html index.htm
Options +FollowSymLinks -Multiviews -Indexes
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?page=$1

期望的效果是index.php将加载GET中请求的页面(/ events-diary = index.php?page = events-diary)&这很好。

但是我有一些需要访问的REAL目录,例如/ admin /

上面的.htaccess在我的家用电脑MAMP上完全正常工作,它在我的亚马逊Micro上工作得非常好,它在部署服务器上不起作用ipage.com

当您输入/ admin时,它将重定向到根索引。当你键入/admin/index.php它可以工作,但你必须指定index.php

我无法弄清楚它何时似乎忽略了!-d

更新:

index.php包含以下PHP

if(!isset($_GET['page'])){
    header("Location: home");
    exit;
}
$line=page_content($_GET['page']);

请注意,这在其他2台服务器上运行正常,我不明白为什么它在3日会表现不同。

3 个答案:

答案 0 :(得分:1)

使用:

V

ng-repeat="serviceSchedule in getServiceScheduler(institutionUserConnection)"大写ng-repeat="serviceSchedule in preCalculatedServicesObjectInScope" 对于Apache,在某些情况下,大/小写非常重要

答案 1 :(得分:0)

以下是一组可能适合您的重写规则:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?page=$1 [NC,L]

您是否正在尝试将内容路由到/admin/index.php?如果是这样,您可以创建.htaccess的副本,将其上传到/ admin目录并将RewriteBase设置为/ admin。

或者,如果你想在/ admin目录中关闭重写引擎,你可以创建一个包含以下内容的.htacess文件:

RewriteEngine off

答案 2 :(得分:0)

难以在评论中发布这些建议,以便求助。

尝试此规则:

iOS 8
相关问题