Skip to content

make it work for virtualhost #1

@yanliu

Description

@yanliu

The current .htaccess config allows only one-level access. For example, index.php, Rest.php, and .htacess can't be under /var/www/myweb/rest/, nor can they be in a directory other than /var/www/. The latter is often the case for virtualhost configurations.

An easy fix is to add RewriteBase directive to .htaccess or in virtualhost config in /etc/apache2/sites-available/default. An example of virtualhost url is as below:

<VirtualHost *:80>

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

... ...

Alias /wsrest/ "/opt/test/rest/examples/"
<Directory /opt/test/rest/examples/>
    RewriteEngine On
    RewriteBase /wsrest/

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^(.*)$ index.php?RESTurl=$1 [QSA,NC,L]

    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.*)$ index.php [QSA,NC,L]

    RewriteCond %{REQUEST_FILENAME} -s
    RewriteRule ^(.*)$ index.php [QSA,NC,L]
</Directory>

By default, RewriteBase points to /var/www, but above setting lets Apache2 know it should use alias /wsrest/, instead of physical location /var/www.

Hope it helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions