My drupal site has a .htaccess
file on which I am redirecting
the page without changing the URL
, Its working fine on local server
& other servers
but when I upload the files & databases to pantheon server
It will not redirect the page saying 404 not found
. I placed .htaccess
at the root of code
folder, I tried placing it in server root
folder, sites
folder & themes
folder but nothing works for me. Can any body know what is the correct placement of .htaccess
in drupal
site on pantheon
? & why my .htaccess
not working on pantheon
?
-
check your server rewrite mode – Lucifer Apr 16 '15 at 15:03
4 Answers
Because Pantheon servers use Nginx, and they don't enable .htaccess support.
You should contact them directly to discuss your options.
You can, however, perform redirects using Drupal’s settings.php, please see:
https://pantheon.io/docs/articles/sites/code/redirect-incoming-requests/

- 865
- 1
- 11
- 28
Technically running Nginx with varnish. redirects & redirect incoming requests
// 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();
}

- 2,187
- 1
- 25
- 40

- 1
- 1
-
-
Hi @TimS. Pantheon uses Fastly for redirects is the new CDN / redirect is done on the edge so 301's on Pantheon are unique [pantheon redirects] (https://pantheon.io/docs/guides/launch/redirects/) because the server does not use Apache at all, therefore, can not utilize **Apache HTaccess** So to replace Apache they use Nginx, Varnish & an All Varnish CDN called Fastly they ask you to use look at this [htaccess Alternative] (https://pantheon.io/docs/htaccess/) I hope that helps, Tom – Thomas Zickell Feb 09 '18 at 23:38
Pantheon does not use htaccess files found because it does not use Apache. Pantheon uses Varnish and Nginx combined with the fastly CDN is now standard on all updated HTTPS installs.
"Redirects should be managed in PHP, since .htaccess is ignored. For details, see Using PHP as an htaccess Alternative." https://pantheon.io/docs/htaccess/
Configure redirects to the primary domain with HTTPS in settings.php
The redirect set up for Pantheon is extremely unique. It is able to allow PHP redirects to go straight to the varnish layer without the traditional latency of PHP redirects.
For Drupal 7 Add the following to the end of your settings.php file (replace 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();
}
}
See https://pantheon.io/docs/guides/launch/redirects/
https://pantheon.io/docs/domains/
For HTTPS https://pantheon.io/docs/http-to-https/
Redirect to Subdirectories or Specific URLs
To redirect from a subdomain to a specific area of the site, use the following:
// 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();
}
For Drupal 8 (thought this may be helpful too as Drupal 8 & Drupal 7 have slightly different redirect set ups) Add the following to the end of your settings.php file (replace 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) .'$');
}
}

- 1
- 1