【问题标题】:example.com/dir/index.php works but example.com/dir/ doesn'texample.com/dir/index.php 有效,但 example.com/dir/ 无效
【发布时间】:2013-03-08 02:25:03
【问题描述】:

我在 Linux CENT OS 6.3 上使用最新的 php 和最新的 apache,

在 httpd.conf 我得到了

DirectoryIndex index.php

<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

当我去:

example.com/mydir/index.php 

它有效,但它不适用于 example.com/mydir/

这对我来说是个问题。

实际上可能与 .htaccess 文件中的某些内容有关:

RewriteEngine on
options +FollowSymLinks

RewriteRule    ^([A-Za-z-0-9-_.]+)/pics/([A-Za-z-0-9-_.]*.*)?$ users/$1/pics/$2
#levanta de users/pics

RewriteRule    ^([A-Za-z-0-9-_.]+)/vids/([A-Za-z-0-9-_.]*.*)?$ users/$1/vids/$2
#levanta de users/vids

RewriteCond    %{REQUEST_URI} ^.*\.(html|png|jpg|gif|jpeg|css|js)
RewriteRule ^([^/]+)(/(.*))?$ - [L]


RewriteCond    %{REQUEST_URI} !settingsd
RewriteRule ^settings settingsd/settings.php

RewriteRule ^lists/ master/index.php
RewriteRule ^lists/(.*)$ $1


RewriteRule ^index\.(php) master/index.php
#levanta de master/


RewriteCond    %{REQUEST_URI} !.*\.(css|js|php)|pokes|settings|subgram
RewriteRule   ^([A-Za-z-0-9-_.]+)?$ master/$2

RewriteCond    %{REQUEST_URI} !pokesd
RewriteRule ^pokes(.*)$ pokesd/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond    %{REQUEST_URI} !pokes|subgram
RewriteRule    ^([A-Za-z-0-9-_.]+)/([A-Za-z-0-9-_.]+.php)?$    master/$2
#levanta de master/


RewriteRule   ^messages/ messages.php

RewriteRule    ^notes/me/ notes/notes.php 
RewriteRule    ^notes/drafts/ notes/notes_drafts.php
RewriteRule    ^notes/tagged/ notes/notes_tagged.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !photos_albums|photos_stream
RewriteRule ^([A-Za-z-0-9-_.]+)/photos $1/view_photos.php
RewriteRule ^([A-Za-z-0-9-_.]+)/photos_albums $1/view_photos.php?sk=photos_albums
RewriteRule ^([A-Za-z-0-9-_.]+)/photos_stream $1/view_photos.php?sk=photos_stream

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z-0-9-_.]+)/friends $1/view_friends.php


RewriteCond    %{REQUEST_URI} !listsd
RewriteRule ^bookmarks/lists(.*)$ bookmarks/listsd/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^v(.*)$ v/video_embed.php?sbid=$1

RewriteCond    %{REQUEST_URI} !.*\.(css|js|php)|notes/me/|notes/drafts/|notes/tagged/
RewriteRule    ^notes/ notes/



RewriteRule ^r.php$ gvrrgvrr45.php$1

这与那里的规则有关,因为当我将其全部剥离并上传到服务器时,它突然起作用了,同样的 .htaccess 在 Windows 中工作,但在此配置中不起作用。

【问题讨论】:

  • 如果您将 index.html 添加到目录中,那么 /mydir/ 是否有效?不确定 Linux,但在 Windows 中,您必须设置默认文档。
  • 是的,它不适用于 index.html
  • 是的,我肯定会修复那个 htaccess 文件,不过它在另一个服务器配置上运行良好。

标签: apache httpd.conf


【解决方案1】:

它与 .htaccess 无关。这是你的 Apache 设置 (/etc/httpd.conf)

检查您的 DirectoryIndex 指令设置。它至少应该有index.php 来支持您的需求:

DirectoryIndex index.html index.htm index.shtm index.shtml index.php  

或删除任何不符合您需要的条目。

【讨论】:

  • 但是如果我剥离 .htaccess 内容并上传它就可以了。它是 httpd.conf 中的DirectoryIndex index.php
  • 最有可能出现问题的是master/index.php 行,但您不在该目录中。
猜你喜欢
  • 1970-01-01
  • 2011-05-30
  • 1970-01-01
  • 1970-01-01
  • 2021-10-11
  • 2011-12-13
  • 2014-10-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多