htaccess文件列出目录而不是使用index.php

时间:2013-08-16 00:52:40

标签: .htaccess wamp

我正在使用nanoCMS(来自mini-print.com)的网站。 和他们提供的htaccess文件。

目录结构是 -

cms/
  error404.php
  htaccess-laplume.txt
  htaccess.txt
img/
  readme.txt
进入localhost/

, 我正在获取文件列表而不是重定向到/cms/index.php

我无法弄清楚这一点! 任何人都可以提出建议吗?

(这是htaccess文件)

# Edit and save this file as .htaccess before uploading
AddDefaultCharset UTF-8

Options +FollowSymLinks -Indexes
RewriteEngine On
DirectoryIndex index.php

ErrorDocument 404 /error404.php

RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /cms/index.php [L]

RewriteCond %{REQUEST_URI} ^/cms/inc/menu\.php$ [OR]

RewriteCond %{REQUEST_URI} ^/cms/inc/inmenu\.txt$ [OR]

RewriteCond %{REQUEST_URI} ^/cms/admin/list\.php$ [OR]

RewriteCond %{REQUEST_URI} ^/cms/([A-Za-z0-9_-]+)\.txt$ [OR]

RewriteCond %{REQUEST_URI} ^/cms/comments/([A-Za-z0-9_-]+)\.txt$ [OR]

RewriteCond %{REQUEST_URI} ^/img/$

RewriteRule .* - [F]


RewriteCond %{REQUEST_URI} ^/cms/$
RewriteRule ^cms/$ / [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /cms/([A-Za-z0-9_-]+)\.php\ HTTP/
RewriteRule ^cms/([A-Za-z0-9_-]+)\.php$ /$1 [R=301,L]

RewriteCond %{REQUEST_URI} !^/index$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([A-Za-z0-9_-]+)\ HTTP/
RewriteRule ^([A-Za-z0-9_-]+)$ /cms/$1.php [L]

1 个答案:

答案 0 :(得分:0)

您需要将htaccess文件移动到文档根目录,否则访问/将不会触及/cms/文件夹中的任何内容。

此外,您需要确保 httpd.conf 文件中的AccessFilename设置为htaccess.txt。否则,您只需将htaccess.txt重命名为任何访问文件名定义为。您还应该确保加载重写模块,该模块也应该在 httpd.conf 文件中,并且看起来像这样:

LoadModule rewrite_module modules/mod_rewrite.so

确保该行已注释掉。