I have a WordPress installed in /var/www/wordpress/
and my own code in /var/www/project/
Now comes the following problem:
When I try to access example.com/client/
or example.com/admin/
it should link to /var/www/project/
and execute the .htaccess + index.php from there.
I have tried to place an Alias directive in the Apache config with partial success.
Alias /admin/ /var/www/project
Alias /client/ /var/www/project
When I access example.com/client/
it works fine, but as soon as I request example.com/client/login
it failes with File does not exist: /var/www/project/login
error.
The .htaccess
in /var/www/project
looks like
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.*)$ index.php?module=$1&task=$2 [L,QSA]
First of all: my pet peeve, quoted from from the manual on .htaccess files:
Second: the canonical answer to almost all mod_rewrite questions is here
I'm not 100% sure, but I think that by setting the RewriteBase to
/
the internal redirect as you have it will be to example.com/index.php and not to /var/www/project/index.php. Additionally I think the PT flag is required to take into account the Alias matching.You may want to try
The documentation for Alias shows that this is the expected behavior. Alias appends any trailing paths after the aliased path.
I think what you want is to throw away the additional path information in the alias, by
That should send the request to /var/www/project, while leaving the URL path of the original request intact for processing by the RewriteRule.