I would like to redirect to https and add this code to a .htaccess file for Drupal. Where should I place this file?

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.domainname\.com*
RewriteRule ^(.*)$ https://domainname.com/$1 [L,R=301]

on https://developers.openshift.com/faq/troubleshooting.html#_how_do_i_redirect_traffic_to_https it says web root.


Found one .htaccess file in (see attached screenshot) app-root/data/downloads/drupal-7.43

Drupal webroot on Openshift

  • I'm not at a computer to check, but fairly sure the file should just be in the root of the GIT repo (I can't remember if that is the web root or if there is some application home directory). – David Hutchison May 30 '16 at 8:20
  • The htaccess content also differs from the one on the page you linked to (which I've used in the past). I don't know if your htaccess file is correct or not. – David Hutchison May 30 '16 at 8:22

You need to place it in the web root, at the base of your site.

If your site is in /var/www/mysite.com/public, then the file would go in /var/www/mysite.com/public/.htaccess.

  • Thanks for the quick reply. I can't find any var/www folder on Openshift. I've attached a link that shows some of the folders. I tried placing the .htaccess file in app-root, but it seems no file can be saved there. – user24957 May 30 '16 at 6:27
  • No one here can guess your installation's directory structure. Don't you know where you uploaded or installed Drupal? Perhaps searching with a command like find / -name index.php might point you in the right direction, but it could take a while to run. – Julie Pelletier May 30 '16 at 6:30
  • I used drupal quickstart and the openshift file structure is quite complex and unconventional compared to traditional hostings I am used to. I found one .htaccess file and edited the question now. – user24957 May 30 '16 at 6:44
  • Then you should look for it elsewhere as it would make no sense to install a program or website inside a download directory, wouldn't it? – Julie Pelletier May 30 '16 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.