.htaccess在上传到万神殿服务器时无法在drupal7上工作



我的drupal站点有一个.htaccess文件,我在该文件上是redirecting页面,而不更改URL,它在local server&其他CCD_ 5,但是当我上传文件&数据库到pantheon server它不会重定向说404 not found的页面。我把.htaccess放在code文件夹的根上,我试着把它放在server root文件夹、sites文件夹&themes文件夹,但对我来说什么都不起作用。有人能知道.htaccesspantheondrupal站点的正确位置吗&为什么我的.htaccess不在pantheon上工作?

因为Pantheon服务器使用Nginx,并且不支持.htaccess。

你应该直接联系他们讨论你的选择。

然而,您可以使用Drupal的settings.php执行重定向,请参阅:

https://pantheon.io/docs/articles/sites/code/redirect-incoming-requests/

Pantheon运行nginx,它忽略.htaccess文件。

从技术上运行带有清漆的Nginx。重定向&重定向传入请求

// 301 Redirect from /old to /new.
if (($_SERVER['REQUEST_URI'] == '/old') &&
(php_sapi_name() != "cli")) {
header('HTTP/1.0 301 Moved Permanently');
header('Location: /new');
exit();
}

Pantheon不使用找到的htaccess文件,因为它不使用Apache。Pantheon使用Varnish和Nginx以及fastly CDN,现在已成为所有更新HTTPS安装的标准配置。

"重定向应该在PHP中管理,因为.htaccess被忽略。有关详细信息,请参阅使用PHP作为htaccess替代方案。">https://pantheon.io/docs/htaccess/

在settings.php 中使用HTTPS配置到主域的重定向

为万神殿设置的重定向是非常独特的。它能够允许PHP重定向直接进入清漆层,而没有PHP重定向的传统延迟。

对于Drupal 7,将以下内容添加到settings.php文件的末尾(替换www.example.com):

if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && php_sapi_name() != 'cli') {
// Redirect to https://$primary_domain in the Live environment
if ($_ENV['PANTHEON_ENVIRONMENT'] === 'live') {
/** Replace www.example.com with your registered domain name */
$primary_domain = 'www.example.com';
}
else {
// Redirect to HTTPS on every Pantheon environment.
$primary_domain = $_SERVER['HTTP_HOST'];
}
if ($_SERVER['HTTP_HOST'] != $primary_domain
|| !isset($_SERVER['HTTP_X_SSL'])
|| $_SERVER['HTTP_X_SSL'] != 'ON' ) {
# Name transaction "redirect" in New Relic for improved reporting (optional)
if (extension_loaded('newrelic')) {
newrelic_name_transaction("redirect");
}
header('HTTP/1.0 301 Moved Permanently');
header('Location: https://'. $primary_domain . $_SERVER['REQUEST_URI']);
exit();
}
}

请参阅https://pantheon.io/docs/guides/launch/redirects/

https://pantheon.io/docs/domains/

对于HTTPShttps://pantheon.io/docs/http-to-https/

重定向到子目录或特定URL

要从子域重定向到网站的特定区域,请使用以下命令:

// Redirect subdomain to a specific path.
if (isset($_SERVER['PANTHEON_ENVIRONMENT']) &&
($_SERVER['HTTP_HOST'] == 'subdomain.yoursite.com') &&
// Check if Drupal or WordPress is running via command line
(php_sapi_name() != "cli")) {
$newurl = 'http://www.yoursite.com/subdomain/'. $_SERVER['REQUEST_URI'];
header('HTTP/1.0 301 Moved Permanently');
header("Location: $newurl");
exit();
}

对于Drupal 8(认为这可能也有帮助,因为Drupal 8和Drupal 7的重定向设置略有不同)将以下内容添加到settings.php文件的末尾(替换www.example.com):

if (isset($_SERVER['PANTHEON_ENVIRONMENT']) && php_sapi_name() != 'cli') {
// Redirect to https://$primary_domain in the Live environment
if ($_ENV['PANTHEON_ENVIRONMENT'] === 'live') {
/** Replace www.example.com with your registered domain name */
$primary_domain = 'www.example.com';
}
else {
// Redirect to HTTPS on every Pantheon environment.
$primary_domain = $_SERVER['HTTP_HOST'];
}
if ($_SERVER['HTTP_HOST'] != $primary_domain
|| !isset($_SERVER['HTTP_X_SSL'])
|| $_SERVER['HTTP_X_SSL'] != 'ON' ) {
# Name transaction "redirect" in New Relic for improved reporting (optional)
if (extension_loaded('newrelic')) {
newrelic_name_transaction("redirect");
}
header('HTTP/1.0 301 Moved Permanently');
header('Location: https://'. $primary_domain . $_SERVER['REQUEST_URI']);
exit();
}
// Drupal 8 Trusted Host Settings
if (is_array($settings)) {
$settings['trusted_host_patterns'] = array('^'. preg_quote($primary_domain) .'$');
}
}

相关内容

  • 没有找到相关文章

最新更新