2

I just have Drupal 7 and 8 installed in my localhost on Opensuse Leap. With Drupal 7 I cannot pass the clean urls test, however the site is completely functional. By clicking the links on the menu I can access localhost/drupal7/?q=admin/dashboard or localhost/drupal7/?q=admin/people (for example).

In Drupal 8 I can access the front page localhost/drupal8 but when I click some link, for example "Log in", I'm redirected to localhost/htdocs/drupal8/user/login. And I get an Apache 404 error. I don't understand why the server redirects to another directory when both installations are using the same configuration file.

I already tried all drupal.org apache-related tutorials without success.

Does anybody know how to solve this issue?

  • What is your Apache configuration? Is mod_rewrite enabled and an AllowOverride set on the Drupal directory? – cilefen May 1 '16 at 19:06
  • @cilefen mod_rewrite is enabled. When I put following code: <Directory /srv/www/htdocs> AllowOverride All RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] </Directory> in httpd.conf.local I get an 403 error for the whole site (forbidden access). – Jorge Montoya May 1 '16 at 19:13
  • 1
    You should only need AllowOverride All, and let Drupal's .htaccess handle the redirect. The .htaccess is there, yes? – cilefen May 1 '16 at 21:56
  • @cilefen .htaccess is there. Have tried with your proposed solution. Same result. – Jorge Montoya May 1 '16 at 23:49
  • @cilefen I put a garbage string in .htaccess to check if the host was even reading it and I got an error 500, so the .htaccess file was ok. When I erased the string and saved the file again, the site magically started to work. That was weird, but finally I got my site running. Thank you – Jorge Montoya May 2 '16 at 2:51
0

I ran into this issue as well moving to opensuse leap from another distribution. There was more than one problem.

  1. Even if rewrite_module is listed in loadmodule.conf, this file is not not read without a change to httpd.conf. You can check if the module is loaded with

    apache2ctl -M

  2. As is posted elsewhere Options and AllowOverride arguments need to be placed within the relevant Directory tags.

  3. If there is a subdirectory of the webserver, there needs to be a RewriteBase argument given in the .htaccess file.

Try this to get things working:

In file /etc/apache2/default-server.conf Within the <Directory> tags add or edit the Options and AllowOverride lines to

Options All
AllowOverride All

In file /etc/apache2/loadmodule.conf add

LoadModule rewrite_module    /usr/lib64/apache2-prefork/mod_rewrite.so

In file /etc/apache2/httpd.conf uncomment the IfDefine tags

    #<IfDefine !SYSCONFIG>
  Include /etc/apache2/loadmodule.conf
#</IfDefine>

In file /srv/www/htdocs/NAMEOFYOURSUBDIRECTORYHERE/.htaccess add a line

RewriteBase /NAMEOFYOURSUBDIRECTORYHERE

Check if the configuration file "Syntax is OK." It will probably complain that some modules have already been loaded, but that's alright.

 apache2ctl configtest

Restart Apache

systemctl stop apache2; sleep 5; systemctl start apache2

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.