我已将此代码放在.htaccess我要保护的文件夹的文件中:
AuthName "restricted area"
AuthType Basic
AuthUserFile /home/#/#/#/#/#/.htpasswd
require valid-user
Run Code Online (Sandbox Code Playgroud)
在同一个文件夹中,我放置了这个.htpasswd:
my:pass
Run Code Online (Sandbox Code Playgroud)
当我转到受保护文件夹的URL时,浏览器一直在问我一遍又一遍的密码,即使我正在输入正确的密码.
我知道提到的根目录AuthUserFile是可以的,因为我发现它:
<?php
$dir = dirname(__FILE__);
echo "<p>Full path to a .htpasswd file in this dir: " .
$dir . "/.htpasswd" . "</p>";
?>
Run Code Online (Sandbox Code Playgroud)
哪里出了问题?
假设我的访客到达:
mydomain.com/nice-url/?p1=a&p2=b
我希望他们被重定向到:
mydomain.com/nice-url/?p1=a
(可能与header("Location:)
所以我想把绳子剥掉p2=b。
由于这只是一个示例,可能还有许多其他参数,因此我正在寻找最明智的解决方案,包括以下方法:
p2。p1还要记住,这nice-url也可以是各种不同的事情,例如:
name-number-one,name-number-two, ETC。
另外,我不寻找.htaccess解决方案,因为我想将剥离参数的值存储在会话中。
我希望"eye"图标一方面显示为现在(在按钮上方,所以我认为z-index不会有帮助),另一方面我希望按钮可以点击它的表面,也意味着在眼睛区域.
另外,有更好的方法来定位眼睛吗?因为一旦我使用不同的文字然后"点击我",我将不得不相应地设置眼睛的绝对位置.有什么办法更好地定义它?
<form action="1.php" method="POST" target="_blank">
<input type="submit" class="button" value="Click Me"><span class="fa fa-eye fa-lg foo" "></span>
</form>
.foo{
color:red;
font-size:1.7em;
position: absolute;
height: 11px;
top: 18px;
left: 15px;
pointer-events: none;
}
.button {
display: inline-block;
zoom: 1;
line-height: normal;
white-space: nowrap;
vertical-align: baseline;
text-align: center;
cursor: pointer;
-webkit-user-drag: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
font-family: inherit;
font-family: arial;
font-size: 17px;
padding: .5em .9em .5em 2em;
text-decoration: none;
border-radius: 4px;
text-shadow: 0 1px 1px rgba(0, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我有一个file.php位于www.example.com/folder/.
我希望该文件对位于www.example.com/include/.
如果我只是使用:
<?php include './include/footer.php';?>
它不起作用,因为它会尝试在 所在的物理文件夹中搜索file.php,而我需要它来引用我的域的根目录。
我在一个数据库中有各种产品,每个产品都有自己的价格,输出产品价格的模式是:
$product[i]["price"]
我还有各种“产品类型”,它们是在我的代码中手动定义的,每个都有与每个产品相应的索引号:
$type1="normal"
$type2="normal"
$type3="special"
...
Run Code Online (Sandbox Code Playgroud)
我想根据每个产品的价格和类型回显一条消息。
我的代码模式将是这样的:
<p> lorem <?php echo function_output($product[1]["price"],$type1)?><p>
<p> ipsum <?php echo function_output($product[2]["price"],$type2)?><p>
<p> done <?php echo function_output($product[3]["price"],$type3)?><p>
Run Code Online (Sandbox Code Playgroud)
(lorem ipsum东西意味着我在代码中有一些静态内容)。
回声线应该是:
如果价格是0--><span class="free">Free</span>
如果价格> 0-->回声$符号+ 价格$product[i]["price"]
默认/回退--> 不回显任何内容
如果type是special,不管价格是多少 --> EchoIt's
special
直觉上,这听起来像是用switch命令处理的事情,但我真的不知道如何按照我想要的方式使用它,这可能涉及到一个函数。我只知道最基本的switch命令形式,我假设我的代码应该是这样的:
$my_text = function_output($product[i]["price"],$type);
switch ($product[i]["price"]) {
case $product[i]["price"]=="0":
$message = '<span class="free">Free</span>';
break;
case $product[i]["price"]>"0":
$message = '$product[i]["price"]';
break;
case …Run Code Online (Sandbox Code Playgroud) php ×3
.htaccess ×1
.htpasswd ×1
apache ×1
css ×1
css-position ×1
function ×1
html ×1
include ×1
include-path ×1
passwords ×1
php-include ×1
positioning ×1
z-index ×1