.htaccess rewrite not working?

I have the following virtual host in /etc/apache2/vhosts.d/ip-based_vhosts.conf:

<VirtualHost test.local:80>
ServerAdmin webmaster@test.local
ServerName test.local
DocumentRoot /home/web/test.net/html

ErrorLog /var/log/apache2/test-error.log
CustomLog /var/log/apache2/test-access.log combined

HostnameLookups Off
UseCanonicalName Off
ServerSignature On

<Directory "/home/web/test.net/html">
  Options Indexes FollowSymLinks
  AllowOverride All

  <IfModule !mod_access_compat.c>
  Require all granted
  </IfModule>
  <IfModule mod_access_compat.c>
  Order allow,deny
  Allow from all
  </IfModule>
  DirectoryIndex index.php
</Directory>
<IfModule proxy_fcgi_module>
  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/home/web/test.net/html/$1
 </IfModule>
</VirtualHost>

And in /home/web/test.net/html I have:

.htacess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

index.php

<?php echo $_SERVER'REQUEST_URI']; ?>

When I visit http://test.local I get correctly “/” (without quotes).

But when I visit anything else, e.g. http://test.local/abc I get a 404 page instead of “/abc”.

How can I solve this to work properly?

Did you set up your website using the YAST http-server module?
AFAIK doing so configures various including your website permissions correctly.

Also, I’d recommend you use /srv/www/ as your default website document root.
By creating a document root in your home directory, you could be introducing permissions complexity.
For websites running anywhere other than /srv/www, I generally use some other webserver like nodejs or nginx, both of which are more flexible invoking websites practically anywhere in your file system.

TSU

Yes.

Also, I’d recommend you use /srv/www/ as your default website document root.

I need to have it the way I have configured it.

By creating a document root in your home directory, you could be introducing permissions complexity.

No. Permissions are fine. I have a dedicated home directory and user group for websites, so everything checks in terms of permissions.

Not sure what you are trying to do here. Do you have an index.php in /test.local/ and in test.local/abc? Because that is what your rewrite is calling for. If not, you will get your “File Not Found” 404 error.

I am trying to route all requests through index.php.

Do you have an index.php in /test.local/ and in test.local/abc?

I have index.php in /home/web/test.net/html as explained.

Because that is what your rewrite is calling for. If not, you will get your “File Not Found” 404 error.

No. The exact same configuration works as I want it on my web hosting but for some reason I can’t get it to work on openSUSE.

Relative location of your htaccess on your actual website?

Relative location of your htaccess on your test system?

/home/<myusername>/<mywebsite>/html

Relative location of your htaccess on your test system?

/home/web/test.net/html

Not sure what you mean by relative.

You are replacing the URL with a URI and mod_rewrite is relative paths.

I really have no idea what you imply. As I said: the exact same files (.htaccess and index.php) work as expected on my web hosting. I am simply trying to make them work on my local openSUSE system. Can you help?

You information that the same configuration works to your satisfaction on another system is missing from your first post here (it only pops up, not very prominent, in post #5 above). The result is most probably that people here concentrate their efforts in trying to help you on the wrong details.

When something works different on system A then on system B. to me it seems logical to find the differences between A and B. First of course are the levels of software different? While you reported that you run Leap 42.1, we can find out what level of Apache you use. We however know nothing about what is used on that web hosting system. When they are different, what does the documentation say about configuration differences between the two (e.g. IIRC there is a difference with Allow/Deny in recent Apache versions)? When the same, we then can concentrate on other aspects.

I found it. The rewrite module was disabled in the apache config.
Everything works now.

Thanks everyone for your time!