小编Sha*_*ane的帖子

阻止 WordPress 从 301 重定向 /index.php 到 /

我需要能够浏览到http://www.example.com/index.php,但 WordPress 会自动 301 将其重定向到http://www.example.com/

是否可以仅针对主页停止此重定向?

这是我的 .htaccess 文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Run Code Online (Sandbox Code Playgroud)

php wordpress .htaccess http-status-code-301 url-redirection

5
推荐指数
1
解决办法
3385
查看次数

我是否滥用C#泛型?

我倾向于严重依赖仿制药,但我担心我会误用它们.

例如,我有一个Entity包含子类字典的子类Component,组件的类型是键,组件是值.例子可以是一个PositionComponent,ColorComponent等等.

我有分离和获取组件的方法,定义如下:

class Entity
{
    Dictionary<Type, Component> components;

    //...

    void DetachComponent<T>() 
        where T : Component 
    {
        components.Remove(typeof(T));
    }

    T GetComponent<T>()
        where T : Component
    {
        return (T)components[typeof(T)];
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在讨论使用的替代方法只是使函数使用参数:void DetachComponent(Type componentType),但我不喜欢调用每个方法,如:entity.DetachComponent(typeof(ColorComponent));

这是滥用泛型吗?我通常对容器类执行此操作,因为使用类型作为键的键值对对我来说很有意义.

c# generics dictionary key-value

4
推荐指数
1
解决办法
142
查看次数

添加新链接时重置jQuery'On Click'绑定器

$(document).ready(function(){
    var links = $('body').find('a.internal');

    links.on('click', function(e){
        //pull page with ajax and replace the content with this response

        //replace current links, as some are added from ajax response
        links = $('body').find('a.internal');

        e.preventDefault();
    })
});
Run Code Online (Sandbox Code Playgroud)

我猜测,因为links.on()当文档准备就绪时只有一个被调用,它永远不会被任何可能创建的新链接"更新".在我的ajax呼叫之后,我将如何重置此绑定器?

感谢您及时的回复.这就是诀窍!

javascript ajax jquery

2
推荐指数
1
解决办法
129
查看次数

请求'file.css'时发送'file.php'

我想在我的css文件中包含PHP,但我不想在站点范围内更改URL.是否可以使用HTACCESS style.phpstyle.css请求时提供服务?这是我到目前为止所尝试的:

RewriteRule /_css/style.css /_css/style.php  
Run Code Online (Sandbox Code Playgroud)

或者,更好的是:允许我保留扩展名,但让HTACCESS将其视为PHP文件?我对HTACCESS知之甚少.谢谢您的帮助.

php .htaccess

2
推荐指数
1
解决办法
257
查看次数

使用 PHP 为 Apple Wallet 通行证创建 PKCS #7 分离签名

这对我来说是一个全新的概念,所以我在黑暗中拍摄。

要创建签名文件,请使用与您的签名证书关联的私钥对清单文件进行 PKCS #7 分离签名。包括 WWDR 中间证书作为签名的一部分。您可以从 Apple 的网站下载此证书。将签名写入pass包顶层的文件签名。包括使用 S/MIME 签名时间属性对通行证进行签名的日期和时间。

我的理解:

要创建签名文件,请制作清单文件的 PKCS #7 分离签名

我将openssl_pkcs7_sign使用 flag使用该函数PKCS7_DETACHED

使用与您的签名证书关联的私钥。

我将使用我的 sslcert.pem文件的位置作为signcert参数,并使用cert.key文件的位置作为privkey参数。

包括 WWDR 中间证书作为签名的一部分。

我将在extracerts参数中包含 WWDR 证书的路径

包括使用 S/MIME 签名时间属性对通行证进行签名的日期和时间。

我将包括一个关键的阵列signing-time和价值类似2015-05-03 10:40:00headers参数。

我的代码:

private function createSignature($dir)
{
    $cert = '/etc/ssl/cert.pem';
    $key = '/etc/ssl/private/cert.key';
    $wwdr = '/location/of/apple/wwdr/cert.cer';
    $headers = [
        'signing-time' => (new DateTime())->format('o-m-d H:i:s'),
    ];

    return openssl_pkcs7_sign("$dir/manifest.json", "$dir/signature", $cert, $key, …
Run Code Online (Sandbox Code Playgroud)

php ssl sign ios pkcs#7

2
推荐指数
1
解决办法
2589
查看次数