htaccess-自定义404错误页面无法正常运行

时间:2018-10-09 00:58:26

标签: apache .htaccess file mod-rewrite http-status-code-404

编辑:此问题已解决。请查看我的答案

我的文件.htaccess仅包含以下行(我添加了自定义404错误页面)

ErrorDocument 404 404.php

这是页面404.php的代码:

<?php echo("file not found")?>

问题是,如果我在浏览器中键入例如URL http://127.0.0.1/www/website/this_file_does_not_exist,则页面将显示以下行:

404.php

换句话说,我只能看到自定义404错误页面的文件名,而不是404错误页面的内容。 我已经在stackoverflow上搜索了没有成功的解决方案。 我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

来自Apache documentation

  

ErrorDocument指令的语法为:

for Number,Names,latitude,longitude in zip(dsa['Number'],dsa['Names'],dsa['latitude'],dsa['longitude']):
    folium.Marker(location=[latitude,longitude],
                  icon=folium.DivIcon(
                      html=f"""<div style="font-family: courier new; color: {'lightblue' if Names == 'Josh' else 'green' if Names == 'Jon' else 'red'}">{"{:.0f}".format(Number)}</div>""")
                  ).add_to(m)
m.save(os.path.join('color_popups1231.html'))
     

该操作将被视为:

     
      
  1. 要重定向到的本地URL(如果操作以“ /”开头)。
  2.   
  3. 要重定向到的外部URL(如果操作是有效的URL)。
  4.   
  5. 要显示的文本(如果以上都不显示)。文字必须是   如果它包含多个单词,请用引号(“)包裹。
  6.   

换句话说,如果您要使用本地URL,则必须以“ /”开头:

ValueError: Unknown format code 'f' for object of type 'str'