2

I have a terrible problem: I have written rubbish within the .htaccess file, in order to break my web site, and cause an error 500. Result: nothing, nothing happens, the web site continues to be online.

That is, the .htaccess file is ignored completely. Why does this happen? I understand that this only has an answer: the Apache server is misconfigured. This is absolutely correct? Or are there other possible causes?

My file system: image 1 and image 2.

Originally the website was hosted on a folder within a server (mydomain.com/folder), and everything worked fine. Now I am migrating the website to another server, but within a subdomain. The features of the new server:

  • Subdomain: domain.company.com
  • Apache: 2.4.7 (Ubuntu)
  • Port: 80
  • phpinfo: Open phpinfo

UPDATE.

1) DNS. I checked my subdomain with http://whois.domaintools.com/ and http://mxtoolbox.com/SuperTool.aspx. I found no problems.

2) .htaccess. The file contains RewriteEngine on. RewriteBase is commented, because I don't know what to put when a subdomain. Anyway, no matter what I put in the file, it is completely ignored.

3) My settings.php has:

I cleared the cache Drupal. I cleared the browser cache. I truncate all tables that start with cache_.

It does not work. The file .htaccess remains ignored. This, I can not enable friendly URLs.

closed as off-topic by Clive Mar 30 '16 at 8:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on programming, PHP, SQL, etc. that do not relate directly to Drupal are off-topic here, but can be asked on Stack Overflow." – Clive
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is a common problem on shared-hosting environments. If you don't have access to your server to configure, you'll probably need to contact your hosting provider. – Volker Mar 30 '16 at 6:15
  • Sorry but server config questions are off-topic here unless they have a specific connection to Drupal - an .htaccess being ignored is something more general than that. Contacting your hosting provider would be the best solution – Clive Mar 30 '16 at 8:15
4

This generally happens when your web server does not have access to make the overrides to your webroot.

Check if your httpd.conf file has something of the following format

<Directory "/Applications/MAMP/htdocs">
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

The important piece above is AllowOverride All, which will make possible for your .htaccess file to override the settings.

If you cannot change the settings in this file, I would recommend you to create a .conf file specific to your site (e.g. mysite.conf using the default file 000-default) in on of /etc/apache2/sites-enabled or /etc/apache2/sites-available, and modify the <Directory> tag to point to the root of your site.

Restart Apache in order to make this change visible. The site should now be able to pick up your .htaccess file.

  • Ajit I am agree with you, but on apache server the .htaccees is completely ignored on his case, in generally it is no dependent on the mysie.conf file. Isn't it? BTW +1 for the answer. – Shubham Mar 30 '16 at 7:02
  • @Shubham : As mentioned in answer, the .htaccess is not able to override the configurations probably because of the value set in the httpd.conf which has the settings for all of your webroot (eg. localhost). I suggested to create the own conf file for the purpose of making the change only for one site. Thanks for the +1 btw ;) – AjitS Mar 30 '16 at 7:50
  • @ Ajit thanks for sharing information. Can you please let me know the .htaccess case with NGINX sever. .htaccess file does not work with NGINX server. – Shubham Mar 31 '16 at 6:10
  • It seems an excellent idea to create my own file .conf. I only find one small problem: I do not have access to these folders: /etc/apache2/sites-enabled or /etc/apache2/sites-available. I do not even have access to cPanel. I have only SFTP access. This is my webroot: see. Obviously, I can not restart Apache. – George Berkeley Apr 1 '16 at 3:37
  • @GeorgeBerkeley I that case, I would suggest to talk to your hosting provider and ask them to make those changes at least for your webroot. – AjitS Apr 2 '16 at 5:22
0

Make sure you have:

1) DNS setup properly

2) .htaccess - Look for the RewriteBase setting AND RewriteEngine on

3) settings.php - Look for $base_url and $base_path

Don't forget to clear the cache after you change these settings. If you can't access the site, use drush cc all or login to your database and truncate all tables that start with cache_ (sometimes clearing the cache still leaves persistent entries).

  • Can you edit your question for how you have your sites directory setup? I would comment above but my rep isn't high enough yet. You can up vote me so I can comment above ;) – ccjjmartin Mar 30 '16 at 3:03
  • @george-berkeley I am also trying to understand your question. Are you trying to break your site? – ccjjmartin Mar 30 '16 at 3:08

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