# Apache rewrite rule issue



## fred974 (Oct 1, 2021)

Hi,

I am running a Nextcloud instance using apache and php-fpm. When I look at the Nextcloud setting overview, I always get this message:





In order to fix it, I created a rewrite rule in my vhost but I still get the error:

```
<VirtualHost *:80>
    DocumentRoot "/usr/local/www/nextcloud"
    ServerName cloud.mynextcloud.uk
    <FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>
    DirectoryIndex /index.php index.php
    <Directory /usr/local/www/nextcloud>
       Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews

       <IfModule mod_dav.c>
            Dav off
        </IfModule>

        RewriteEngine on
        RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
        RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
        RewriteRule ^/\.well-known/host-meta https://%{SERVER_NAME}/public.php?service=host-meta [QSA,L]
        RewriteRule ^/\.well-known/host-meta\.json https://%{SERVER_NAME}/public.php?service=host-meta-json [QSA,L]
        RewriteRule ^/\.well-known/webfinger https://%{SERVER_NAME}/public.php?service=webfinger [QSA,L]

    </Directory>
</VirtualHost>
```
Could  anyone provide any advise on how to fix this warning please?

Thank you


----------



## SirDice (Oct 4, 2021)

How is anyone supposed to follow links in a _picture_?


----------



## fred974 (Oct 4, 2021)

SirDice said:


> How is anyone supposed to follow links in a _picture_?


Good point sorry.
Here is the text
---
Security & setup warnings​It's important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.

There are some warnings regarding your setup.

Your web server is not properly set up to resolve "/.well-known/caldav". Further information can be found in the documentation ↗.
Your web server is not properly set up to resolve "/.well-known/carddav". Further information can be found in the documentation ↗.
Please double check the installation guides ↗, and check for any errors or warnings in the log.

Check the security of your Nextcloud over our security scan ↗.


----------



## SirDice (Oct 4, 2021)

fred974 said:


> Good point sorry.


Now I can actually read the documentation it is pointing to


----------



## SirDice (Oct 4, 2021)

fred974 said:


> ```
> RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
> RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
> ```


Documentation says to use:

```
RewriteRule ^\.well-known/carddav /nextcloud/remote.php/dav [R=301,L]
  RewriteRule ^\.well-known/caldav /nextcloud/remote.php/dav [R=301,L]
```

Notice the difference? It does assume you have a /nextcloud subfolder, if I look at your setup it looks like you haven't used a subfolder. So then it should be:

```
RewriteRule ^\.well-known/carddav /remote.php/dav [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav [R=301,L]
```


----------

