首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >htaccess文件列表目录,而不是使用index.php

htaccess文件列表目录,而不是使用index.php
EN

Stack Overflow用户
提问于 2013-08-16 08:52:40
回答 1查看 183关注 0票数 0

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

目录结构是-

代码语言:javascript
复制
cms/
  error404.php
  htaccess-laplume.txt
  htaccess.txt
img/
  readme.txt

进入localhost/时,我得到的是文件列表,而不是重定向到/cms/index.php

我搞不懂这个!有没有人能给我提点建议呢?

(这里是htaccess文件)

代码语言:javascript
复制
# 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]
EN

回答 1

Stack Overflow用户

发布于 2013-08-16 09:41:58

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

此外,您需要确保httpd.conf文件中的AccessFilename设置为htaccess.txt。否则,您可以将htaccess.txt重命名为访问文件名定义的任何名称。您还应该确保您正在加载重写模块,该模块也应该在您的httpd.conf文件中,并且应该如下所示:

代码语言:javascript
复制
LoadModule rewrite_module modules/mod_rewrite.so

确保该行没有被注释掉。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18264185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档