Mod_rewrite - absolute path in .htaccess - inclusion 404

I want to map multiple directories in a url:

www.example.com/manual
www.example.com/login

for directories outside the web root.

My web root

/www/htdocs/customername/site

the manual I want to redirect to is in

/www/customer/some_other_dir/manual

In mod_alias this will be equal

Alias /manual /www/customer/some_other_dir/manual

but since I only have access to .htaccess, I cannot use Alias, so I need to use mod_rewrite.

What I got now after this question is the following:

RewriteRule ^manual(/(.*))?$ /www/htdocs/customername/manual/$2 [L]

this works in the sense that requests are recognized and redirected properly, but I get a 404 that looks like this (note the absolute path):

The requested URL /www/htdocs/customername/manual/resourcename.htm 
was not found on this server.

However, I checked with PHP: echo file_exists(...)and this file definitely exists.

? mod_rewrite, .htaccess. , mod_rewrite .htaccess , , ?

: -, FTP, , FTP.

- , , , .

, .

, 301, .

+1
3

AFAIK mod_rewrite "" ( HTTP). , HTTP 302 .

, , .. ; ( , , FTP ) .

: URL , , .

+2

.htaccess wwwroot.

-, .

.htaccess :

Options +SymLinksIfOwnerMatch

, ,

Options +FollowSymlinks

RewriteRule ^manual(/(.*))?$ /www/htdocs/customername/site/manual/$2 [L]

- /www/customer/some _other_dir/manual

:

ln -s /www/htdocs/customername/site/manual /www/customer/some_other_dir/manual

, , CPanel, Webmin . php/cgi, . , , . , .htaccess.

+2

This tells you what you need to know. The requested URL / www / htdocs / customername / manual / resourcename.htm was not found on this server. It is interpreted RewriteRule ^manual(/(.*))?$ /www/htdocs/customername/manual/$2 [L]to mean rewrite example.com/manual/, as if it were example.com/www/htdocs/customername/manual/.

Try

 RewriteRule ^manual(/(.*))?$ /customername/manual/$2 [L]

instead.

-1
source

Source: https://habr.com/ru/post/1731186/


All Articles