A
A
Andrey2014-11-19 10:20:41
Apache HTTP Server
Andrey, 2014-11-19 10:20:41

How to hide source path after URL rewrite?

All files on the server are stored in the root, in the /apps/sitename.ru/ folder. By default, they all open in the usual way, that is, the www.sitename.ru/i/logo.png page opens the /apps/sitename.ru/i/logo.png file. If the file does not exist, processing is transferred to the controller.
I am using the following rules:

RewriteCond %{DOCUMENT_ROOT}/apps/sitename\.ru/%{REQUEST_URI} -f
RewriteRule ^(.*)$ apps/sitename\.ru/$1 [NC,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.html?_action=$1 [QSA,L]

But I see at least one problem, besides the path www.sitename.ru/i/logo.png, the file is also available at www.sitename.ru/apps/sitename.ru/i/logo.png. Tell me how to make the path www.sitename.ru/apps/sitename.ru/i/logo.png lead to the handler, and not to the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Batulin, 2014-11-19
@DmitryPRG

I would not have done this:
in .htaccess I would have registered that all requests to the address: www.sitename.ru/apps/*
would go to a handler file that could do a redirect or something else.
And the second file would be processed from the root or from the /i/ folder, depending on what you have as the root for processing.
And for all requests, I checked whether there is a file at the local address: www.sitename.ru/apps/sitename.ru/i/logo.png and would display its content in the browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question