.htaccess routing to a subdirectory on the server? working / loading time

I wonder if it is possible to use the .htaccess file to route my domain directly to a subdirectory on my server?

I bought a web hosting package from a regular web host where my .com domain is connected to my root directory of my server. I wonder if it is possible to somehow upload the .htaccess file to the root directory of my server, which automatically routes domain.com (/index.php or /index.html) to domain.com/some-directory / ...

And, of course, I do not want the address bar to be updated to domain.com/some-directory. I want my regular domain to just extract files from a subdirectory instead of the root directory.

Just for a better overview on my server.

So, when calling mydomain.com, it displays index.html (or .php) from my root directory on my server. However, I want mydomain.com to display /subdirectory/index.html.

If possible, how can I do this? This is so bad? Is there something I was not thinking about? is there more boot time or something like that with this approach?

Thanks in advance. Matt

: this is possible with the DNS setting in my web admin panel. I can edit all DNS records.

+2
source share
1 answer

Try putting this in your htaccess file in your document root:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/some-directory/
RewriteCond %{DOCUMENT_ROOT}/some-directory%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/some-directory%{REQUEST_URI} -d
RewriteRule ^(.*)$ /some-directory/$1 [L]

, , mod_dir URL "/some-directory/".


, 2 -f -d , , , . , htaccess , , , . , - URL, 404 /some-directory/. 404 - :

URL/some-directory/blahblahblah .

, /some-directory/.

+2

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


All Articles