loewexy / pdnsmanager

A simple administration interface for PowerDNS nameserver.
Apache License 2.0
175 stars 48 forks source link

How to install in a yet existing vhost? #125

Closed Remitur closed 3 years ago

Remitur commented 4 years ago

Hello. Quickstart provides detailed instructions to install in a new Apache vhost (https://pdnsmanager.org/quickstart/ )

I need to install in a yet existing vhost, having no access to Apache configuration; so I would need to recreate the required rewrite rules in .htaccess

I tried it, but unsuccessfully... :-(

Can you please provide the .htaccess basic structure to be used?

Thank you for your attention

R0Wi commented 4 years ago

Hey, first of all you will have to make sure that Apache is using the .htaccess-files in your webroot. Therefore the corresponding AllowOverride-directive has to be set in the virtualhost file (for example AllowOverride all). You can read more about this here. If you don't have access to the virtualhost files of Apache please contact your provider. In most basic webhosting packages this options should be activated by default so that your .htaccess-files are taken into account by the Apache webserver.

After that you should be able to reach same behaviour like described in the quickstart manual by putting two .htaccess-files into the right place (i'll use the same paths like in the quickstart):

/var/www/html/frontend/.htaccess:

    RewriteEngine On
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
    RewriteRule !^/api/\.* /index.html [L]

/var/www/html/backend/public/.htaccess:

        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^ index.php [QSA,L]

The only problem i see here is that you can't set the Alias directive outside of the virtualhost file (see context here). You could try to immitate a similar behaviour by creating the directory /var/www/html/frontend/api as symlink pointing to the /var/www/html/backend/public. Therefore the Options FollowSymLinks directive has to be set in the first .htaccess-file residing in the directory /var/www/html/frontend/. I didn't try the things with symlinks so it's just a proposal, maybe someone else has a better solution for this.

Anyway, hope this helps :-)