在这里,我们将给大家分享关于如何在Nginx中将index.html设置为根文件?的知识,让您更了解nginx设置根目录的本质,同时也会涉及到如何更有效地angularjs–在HTML中将默认值设置为
在这里,我们将给大家分享关于如何在Nginx中将index.html设置为根文件?的知识,让您更了解nginx设置根目录的本质,同时也会涉及到如何更有效地angularjs – 在HTML中将默认值设置为ng-bind、asp.net-mvc – 将index.html设置为默认页面、htaccess仅将index.html重定向到index.php、html – 如何在IE11 Win8.1中将文档模式设置为Edge的内容。
本文目录一览:- 如何在Nginx中将index.html设置为根文件?(nginx设置根目录)
- angularjs – 在HTML中将默认值设置为ng-bind
- asp.net-mvc – 将index.html设置为默认页面
- htaccess仅将index.html重定向到index.php
- html – 如何在IE11 Win8.1中将文档模式设置为Edge
如何在Nginx中将index.html设置为根文件?(nginx设置根目录)
如何为域名设置index.html,例如https://www.example.com/ – 将用户引导至根目录中的index.html。
我尝试了不同的东西,如:
server { # some configs location = / { index index.html; fastcgi_index index.html; } or location / { index index.html; fastcgi_index index.html; } }
没有什么帮助我。
还有一些其他configuration与位置关键字,但我也评论他们。
使用C#.net挂载其他用户configuration单元
用makefile安装时问问题
为什么hdfs在Hadoop集群中引发LeaseExpiredException(AWS EMR)
在apache localhost服务器上使用.htaccess文件
Nginx:try_files之外的位置
其他“位置”configuration在server {子句:
location ~ .*(css|htc|js|bmp|jp?g|gif|ico|cur|png|swf|htm?|html)$ { access_log off; root $www_root; } location ~ .PHP$ { include /etc/Nginx/fastcgi_params; index index.html; fastcgi_index index.html; fastcgi_param SCRIPT_FILENAME $www_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass 127.0.0.1:9000; # Директива определяет что ответы FastCGI-сервера с кодом больше или равные 400 # перенаправлять на обработку Nginx'у с помощью директивы error_page fastcgi_intercept_errors on; break; } location ~ /.ht { deny all; }
他们都评论和不注,但没有任何帮助。
PS版本是在/etc/Nginx/sites-enabled/domainname.com文件中制作的。
AuthnProviderAlias ldap可以使用Apache2.4.x吗?
如何静态链接使用./configure的Linux软件?
Linuxconfiguration文件库
Nginx与多个symfony2应用程序
有没有Unixconfiguration文件的指导方针
在你的位置块你可以做:
location / { try_files $uri $uri/index.html; }
这会告诉ngingx先查找一个文件名,如果找不到这样的文件,它会尝试uri / index.html。 所以,如果https://www.example.com/的请求来了,它会先查找一个确切的文件匹配,然后找不到,然后检查index.html
location / {是最普通的位置( location { )。 它将匹配任何东西, AFAIU 。 我怀疑是否有location / { index index.html; } location / { index index.html; }因为你网站的每个子目录都有很多重复的内容。
用的方法
try_files $ uri $ uri / index.html index.html;
是不好的,正如上面的评论中提到的那样,因为它返回的index.html页面不应该存在于你的网站上(任何可能的$uri都会以此为结果)。 另外,正如上面的答案中所提到的,在try_files的最后一个参数中有一个内部重定向。
你的方法
location = / { index index.html;
也不好,因为index做内部重定向。 如果你想要的话,你应该能够在特定的location 。 创建例如
location = /index.html {
就像这里提出的那样。 但是,你会有一个工作链接http://example.org/index.html ,这可能是不希望的。 我使用的另一个变体是:
root /www/my-root; # http://example.org # = means exact location location = / { try_files /index.html =404; } # disable http://example.org/index as a duplicate content location = /index { return 404; } # This is a general location. # (eg http://example.org/contacts <- contacts.html) location / { # use fastcgi or whatever you need here # return 404 if doesn't exist try_files $uri.html =404; }
PS 调试 Nginx非常简单(如果你的二进制允许的话)。 只要添加到server {块:
error_log /var/log/Nginx/debug.log debug;
看到那里所有的内部重定向等
答案是将根目录放在位置指令中:
root /srv/www/ducklington.org/public_html;
根据文档以指定顺序检查文件的存在,并使用第一个找到的文件进行请求处理; 处理在当前上下文中执行。 根据root和alias指令从文件参数构建文件的路径。 可以通过在名称末尾指定斜线来检查目录的存在,例如“$ uri /”。 如果找不到任何文件,则将内部重定向到最后一个参数中指定的uri。 重要
内部重定向到最后一个参数中指定的uri。
所以在上一个参数中,如果前两个参数返回false,则应该添加页面或代码。
location / { try_files $uri $uri/index.html index.html; }
angularjs – 在HTML中将默认值设置为ng-bind
<button>Show <span data-ng-bind="data.text" data-ng-init="data.text = 'All';"></span> Names</button>
在此示例中,页面加载时,span设置为innerHTML =’All’.
不过,我希望有一种方式可以做到这一点,而不需要使用ng-init,也许是这样的:
<button>Show <span data-ng-bind="data.text = 'All';"></span> Names</button>
$scope.data = {}; $scope.data.text = "All";
您的标记:
<button>Show <span data-ng-bind="data.text"></span> Names</button>
或者,如果您想跳过控制器代码(由Kohjah Breese提供的评论):
<button>Show <span data-ng-bind="data.text || 'All'"></span> Names</button>
大概在控制器的其他地方会有一些代码会切换这个值,但为了初始化的目的,应该这样做.
编辑:或者,正如tymeJV在评论中指出的(ng-cloak add so {{}}语法不会显示给用户):
<button>Show <span ng-cloak>{{data.text || "All"}}</span> Names</button>
asp.net-mvc – 将index.html设置为默认页面
我试图右键单击index.html并设置为起始页,当我运行它时,url是:http:// localhost:5134 / index.html但是我真正想要的是当我键入:http: // localhost:5134,它应该加载index.html页面。
我的路由配置:
public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home",action = "Index",id = UrlParameter.Optional } ); } }
解决方法
routes.IgnoreRoute("");
htaccess仅将index.html重定向到index.php
我有一个htaccess规则,它将index.html重定向到index.PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$/$1index.PHP [R=301,L]
这很好 – 当我拨打http://mydomainname.com/index.html时,它会将我重定向到http://mydomainname.com/index.php
但是我遇到了一个问题,当子文件夹中有一个名为index.html的文件时,我的htaccess规则将其带到index.PHP.
示例 – http://mydomainname.com/subfolder/index.html到http://mydomainname.com/subfolder/index.php,子文件夹不应该发生这种情况.
有解决方案吗
解决方法:
对于你正在做的事情,这个规则可能有点过于复杂.
你只需要:
RewriteRule ^index.html$/index.PHP [R,L]
html – 如何在IE11 Win8.1中将文档模式设置为Edge
但是上周,我的老板订购了一台装有Windows 8.1的新电脑,而且还有.c. IE 11,我的所有网站看起来都很难看.我检查了F12工具,在仿真选项卡上,它说Documentmode = 7(默认值).如果我把它改成Edge,一切都显示应该是….但是刷新后它只会跳回到7.
我总是使用<!DOCTYPE html>在我的页面上,并始终在过去工作.但是现在,关于win8.1的IE11似乎忽略了它.
我之所以认为它只是Windows 8(.1),是因为我还安装了IE11,但是在Windows7 PC上.
我仔细检查了两个PC的compabilityview列表中没有添加任何网站
在一些搜索之后,我发现< Meta http-equiv =“X-UA-Compatible”content =“IE = edge”/>它的工作原理!
但我找不到任何地方为什么它是这样的,如果有另一个解决方案,而不是打开我创建的每个网站的每个页面,并添加元标记…
我在这里的第一个问题,希望我做得好:-)
解决方法
您可以将X-UA-Compatible作为服务器标头发送,而不是更改每个站点的每个页面.见http://msdn.microsoft.com/en-us/library/jj676913%28v=vs.85%29.aspx
关于如何在Nginx中将index.html设置为根文件?和nginx设置根目录的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于angularjs – 在HTML中将默认值设置为ng-bind、asp.net-mvc – 将index.html设置为默认页面、htaccess仅将index.html重定向到index.php、html – 如何在IE11 Win8.1中将文档模式设置为Edge等相关内容,可以在本站寻找。
本文标签: