RewriteBase /folder1/folder2/
By itself, the RewriteBase
does not do anything. The RewriteBase
directive overrides the base URL-path to be used in relative path substitutions in the RewriteRule
directive. For example, given the following:
RewriteBase /folder1/folder2/
RewriteRule ^foo$ bar [L]
With the above, if you request /foo
then the request will be internally rewritten to /folder1/folder1/bar
because the substitution string bar
is relative. This is the same as stating the following:
RewriteRule ^foo$ /folder1/folder2/bar [L]
That is all the RewriteBase
directive does. You don't strictly need it here, but you can use it if you want to.
and this file is located in "/folder1/folder2/", but it does nothing ...
You need to target requests for the document root, so you can't put this .htaccess
file in the /folder1/folder2/
directory - it simply won't do anything. A .htaccess
file located at /folder1/folder2/.htaccess
will only target requests to /folder1/folder2/
and all subdirectories thereof.
By the sounds of it you want to internally rewrite all requests from the document root to the /folder1/folder2/
directory - effectively hiding /folder1/folder2/
from the user.
For this you need to use something like the following in the /.htaccess
file located in the document root:
RewriteEngine On
RewriteRule !^folder1/folder2 /folder1/folder2%{REQUEST_URI} [L]
The above rewrites any request that is not already for /folder1/folder2
to that subdirectory.
also the user need to be able to include ../../etc/passwd
I'm not sure how you are intending to "include" this, but if you are referring to client-side URL-paths then you should not use relative URL-paths like this. Use root-relative URL-paths eg. /etc/passwd
(from the document root).
How to write a .htaccess
that changes /folder1/folder2/
to /
Note that this .htaccess
file does the complete opposite. It changes URLs that request /
(the document root) to /folder1/folder2/
- which seems to be the requirement in your question. You need to have already changed /folder1/folder2/
to /
in your internal links.