我有一个运行在Linux/UNIX上的网站,但我对.htaccess文件及其语法一无所知。
如果你去http://pr.bananapages.net,系统不会产生任何结果。但是如果添加文件名,它就会出现。例:http://pr.bananapages.net/index.html
注意:指向共享访问主机服务器上的一个子文件夹,但这并不重要,因为当您键入www.bananapages.net/pr/hamshack时(这是快捷的www.bananapages.net/pr/hamshack地址指向的位置),它仍然不会生成index.html文件,而不实际指定它。
我试过了关于DirectoryIndex所能找到的一切,但如果不使用文件名…,就无法使它工作。(index.html)
这是我当前的.htccess文件。
Options -MultiViews
DirectoryIndex system.php index.php
<IfModule mod_rewrite.c>
DirectoryIndex system.php index.php index.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(.*)$
RewriteRule ^(.+[^/])$ http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]
# Google sitemap controller
RewriteRule ^sitemap.xml$ tmp/sitemap.xml [L]
RewriteRule ^tmp/sitemap.xml$ tmp/sitemap.xml [L]
RewriteRule ^index.html$ index.html [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)(\.xml|\.php([0-9]*)|\.tpl|\.phtml|\.ini|\.inc|/)$ system.php?_p=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ system.php?_p=$1 [QSA,L]
</IfModule>
# compresses text, html, javascript, css and xml
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
</IfModule>注意:如果我重命名.htaccess文件,它将工作,而不指定文件名,(index.html)因此。我相当肯定,这个.htaccess文件中有一些东西阻止了它按照所需的方式工作。
发布于 2013-11-10 10:03:04
你可以试试这个:
在你所有的
RewriteCond %{REQUEST_FILENAME} !-f
因此,只在既不是目录也不是文件的情况下才进行重写:
编辑
(在Debian/Apache2 2中测试)。
Options -MultiViews
DirectoryIndex system.php index.php index.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(.*)$
RewriteRule ^(.+[^/])$ http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]
# Google sitemap controller
RewriteRule ^sitemap.xml$ tmp/sitemap.xml [L]
#RewriteRule ^tmp/sitemap.xml$ tmp/sitemap.xml [L]
#RewriteRule ^index.html$ index.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(\.xml|\.php([0-9]*)|\.tpl|\.phtml|\.ini|\.inc|/)$ system.php?_p=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ system.php?_p=$1 [QSA,L]看看能不能更好点?请注意一些注释无限循环重写。
发布于 2014-02-09 02:43:23
我的副驾驶证也有类似的情况。
我希望我的默认主页是login.php,所以如果有人到哪里去http://[ip]/[folder]/,它只会加载我在文件夹中的.htaccess中设置的login.php文件
所以我把“DirectoryIndex login.php”放在.htaccess里,但是
它不会起作用,相反,当我去http://[ip]/[folder]/的时候,我会得到403个,因为我没有任何index.html或index.php
所以..。
我决定检查apache配置文件httpd.conf,在DirectoryIndex下,我将'login.php‘作为已经存在的列表的一部分,然后重新启动httpd服务和
对我起作用了!
发布于 2013-11-11 05:05:34
答案是..。
# Rules for subfolders
# for pr.bananapages.net
RewriteRule ^pr/(.*)$ pr/$1 [L]
# for jm.bananapages.net
RewriteRule ^jm/(.*)$ jm/$1 [L]
# and so on....
RewriteRule ^dr/(.*)$ dr/$1 [L]
RewriteRule ^usvi/(.*)$ usvi/$1 [L]
RewriteRule ^bvi/(.*)$ bvi/$1 [L]
RewriteRule ^kitts/(.*)$ kitts/$1 [L]
RewriteRule ^ar/(.*)$ ar/$1 [L]
RewriteRule ^tt/(.*)$ tt/$1 [L]我不知道为什么会起作用,但它看起来确实有效.戴尔
https://stackoverflow.com/questions/19886448
复制相似问题