在 Apache 中,可以将所有内容重定向到最近的 index.php,使用 .htaccess
示例文件夹结构:
/Subdir
/index.php
/.htaccess
/Subdir
/Subdir/.htaccess
/Subdir/index.php
Run Code Online (Sandbox Code Playgroud)
如果我访问/something它会重定向到根 index.php,如果我访问/Subdir/something它会重定向到Subdir/index.php
这也可以在nginx中完成吗?这应该是可能的,因为在 nginx 文档中它说If you need .htaccess, you’re probably doing it wrong:)
我知道如何将所有内容重定向到根 index.php:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
Run Code Online (Sandbox Code Playgroud)
但是如何在每个父目录中检查 index.php 直到/?
编辑:
我发现这些规则可以满足我的要求:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /Subdir{
try_files $uri $uri/ /Subdir/index.php?$query_string;
}
Run Code Online (Sandbox Code Playgroud)
但是有没有办法让它抽象,比如
location /$anyfolder{
try_files $uri $uri/ /$anyfolder/index.php?$query_string;
}
Run Code Online (Sandbox Code Playgroud)
?
Websockets支持发送 blob,但我们如何用它们发送额外的文本数据?
我的用例是文件上传器。我将每个文件切成多个部分,并一次将最多 3 个部分发送到服务器。在服务器上,我需要一种方法来识别这些切片的顺序,以便我可以重建文件。这就是为什么我需要将切片的索引与 blob 以及文件名一起发送(可以上传多个文件)
有没有办法获取视觉上位于某个元素下方或上方的元素?
这些元素是列表的一部分,我希望能够使用箭头键在列表中导航。左/右移动到上一个/下一个兄弟姐妹,但我不知道如何处理上/下。
$(document).on('keydown', function(e) {
console.log(e.which);
var current = $('li.selected');
switch (e.which) {
case 37:
current.prev().addClass('selected').siblings().removeClass('selected');
break;
case 39:
current.next().addClass('selected').siblings().removeClass('selected');
break;
default:
return true;
}
e.preventDefault();
});
$('li').on('click', function(e) {
$(this).addClass('selected').siblings().removeClass('selected');
});Run Code Online (Sandbox Code Playgroud)
ul {
display: flex;
flex-wrap: wrap;
list-style: none;
}
li {
width: 50px;
height: 50px;
margin: 5px;
border: 1px solid red;
}
li.selected {
background: red;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li class="selected"></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li> …Run Code Online (Sandbox Code Playgroud)Transliterator::listIDs() 将列出 ID,但显然它不是一个完整的列表。
Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();
Run Code Online (Sandbox Code Playgroud)
这有点奇怪,因为 ID 应该是唯一的。这看起来更像是一条规则,但如果我将它传递给createFromRules方法,它就不起作用:)
无论如何,我正在尝试从字符串中删除任何标点符号,但破折号 ( -) 或特定列表中的字符除外。
你知道这可能吗?或者是否有一些文档可以更好地解释音译器的语法?
当鼠标悬停在列表项目上时,该元素将附加到列表项目,并在鼠标移出时分离.
单击该元素时,它将被分离,然后从DOM中删除它所属的列表项.
我的HTML:
<div id="cart">
<ul>
<li> <a data-item="a">item A</a></li>
<li> <a data-item="b">item B</a></li>
<li> <a data-item="c">item C</a></li>
<li> <a data-item="d">item D</a></li>
<li> <a data-item="e">item E</a></li>
<li> <a data-item="f">item F</a></li>
<li> <a data-item="g">item G</a></li>
<li> <a data-item="h">item H</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我的JavaScript:
function plugin(node, opts){
var self = this;
delKnob = $('<i />').text('×');
this.cart = $(node);
delKnob
.on('click', function(){
var item = $(this).parent().find('[data-item]').data('item');
$(this).detach();
self.remove(item);
});
this.cart
.on('mouseenter', 'li', function(){
delKnob.appendTo(this);
})
.on('mouseleave', 'li', function(){
delKnob.detach();
});
}
plugin.prototype = { …Run Code Online (Sandbox Code Playgroud) 有吗?
切换到更少后,我通常最终得到这样的代码:
.topNav{
prop: value;
...
li{
prop: value;
...
&:hover{
...
}
&.active{
prop: value;
...
a{
prop: value;
...
&:hover{
prop: value;
...
span{
...
}
}
span{
...
}
}
}
a{
prop: value;
...
&:hover{
prop: value;
...
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这不好吗?