重写规则使得php页面由一个direcory url结构加载?

时间:2018-03-06 12:42:28

标签: .htaccess url-rewriting

我有以下重写规则:

RewriteEngine On
RewriteRule    ^test    test.php    [NC,L]  

这允许我通过以下方式访问该页面:

http://www.example.com/testhttp://www.example.com/test.php但是如何阻止http://www.example.com/test.php被访问?

由于

1 个答案:

答案 0 :(得分:0)

如果您想直接访问QString QAzureStorageRestApi::generateAutorizationHeader(const QString& httpVerb, const QString& container, const QString& blobName, const QString& currentDateTime, const long& contentLength, const QStringList additionnalCanonicalHeaders, const QStringList additionnalCanonicalRessources) { // Create canonicalized header QString canonicalizedHeaders; for (const QString& additionnalCanonicalHeader : additionnalCanonicalHeaders) { canonicalizedHeaders.append(additionnalCanonicalHeader+"\n"); } canonicalizedHeaders.append(QString("x-ms-date:%1\nx-ms-version:%2").arg(currentDateTime, m_version)); // Create canonicalized ressource QString canonicalizedResource; if (blobName.isEmpty()) { canonicalizedResource = QString("/%1/%2").arg(m_accountName, container); } else { canonicalizedResource = QString("/%1/%2/%3").arg(m_accountName, container, blobName); } for (const QString& additionnalCanonicalRessource : additionnalCanonicalRessources) { canonicalizedResource.append("\n"+additionnalCanonicalRessource); } // Create signature QString signature = generateHeader(httpVerb, "", "", QString::number(contentLength), "", "", "", "", "", "", "", "", canonicalizedHeaders, canonicalizedResource); // Create authorization header QByteArray authorizationHeader = QMessageAuthenticationCode::hash( QByteArray(signature.toUtf8()), QByteArray(QByteArray::fromBase64(m_accountKey.toStdString().c_str())), QCryptographicHash::Sha256); authorizationHeader = authorizationHeader.toBase64(); return QString("SharedKey %1:%2").arg(m_accountName, QString(authorizationHeader)); } uri时显示403 forbidden error页面,则可以使用此规则:

/test.php

如果您想将RewriteCond %{THE_REQUEST} /test\.php [NC] RewriteRule ^test\.php$ - [R=403,L] 重定向到新的uri /test.php,请使用以下内容:

/test