Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正在尝试查找静态网站的自定义.htaccess_.htaccess_Web_Url Redirection - Fatal编程技术网

正在尝试查找静态网站的自定义.htaccess

正在尝试查找静态网站的自定义.htaccess,.htaccess,web,url-redirection,.htaccess,Web,Url Redirection,我正在创建一个新的静态网站。我有folder1和folder2,它们是远程web服务器上的文件夹。这两个文件夹中的每一个都可能包含HTML文件 我希望发生以下事情: 当他键入www.domin.com/folder1/-->时,会在folder1文件夹下显示index.html文件 当他键入www.domin.com/folder1-->错误时 当他键入www.domain.com/folder1/file1/-->时,显示/folder1/file1.html文件 当他键入www.domain

我正在创建一个新的静态网站。我有
folder1
folder2
,它们是远程web服务器上的文件夹。这两个文件夹中的每一个都可能包含HTML文件

我希望发生以下事情:

  • 当他键入www.domin.com/folder1/-->时,会在folder1文件夹下显示index.html文件
  • 当他键入www.domin.com/folder1-->错误时
  • 当他键入www.domain.com/folder1/file1/-->时,显示/folder1/file1.html文件
  • 当他键入www.domain.com/folder/file.html或www.domain.com/folder/file-->时,会显示一个eror:这样的文件不存在
  • 唯一允许的URL是:

    • domain.com/
    • domain.com/about file/
    • domain.com/folder1/
    • domain.com/folder1/file/
    以下解决方案不起作用:当我键入www.domain.com/folder/或/folder/index.html时,会显示doesnotexists.html以查找错误

    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^([^/]+)/$ $1/index.html [QSA,L]  # rule 1
    
    RewriteRule ^([^/]+)/([^/]+)/$ $1/$2.html [QSA,L] # rule 3
    
    RewriteRule ^[^/]+(/[^/]+(\.html)?)?$ doesnotexists.html [L] # rule 2 and 4
    

    好的,如果/folder/index.html/folder/不存在,它应该显示404。你是说/folder*1*/index.html吗?关于访问,您的ErrorLog${APACHE\u LOG\u DIR}/error.LOG说明了什么?是否还有其他错误?

    将显示doesnotexists.html文件。因此,我认为.htaccess规则中存在错误