Get domain name dynamically in htaccess file

-2

I have a .htaccess file with several instructions. I would like to make it more dynamic, that is, to make it more optimized for other sites without having to edit it.

Lines such as those mentioned below refer to the domain name, would like it to look up the domain name automatically, without the need to quote it.

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ 
http://www.nomedodominio.com.br/diretorio/administrador/$1 
[R=301,L]

and

ErrorDocument 404 http://www.nomedodominio.com.br/diretorio/administrador/

Note: I need to keep the path after the domain name:   / directory / admin / .

Thank you in advance.

    
asked by anonymous 10.11.2018 / 17:04

1 answer

3

Just remove the domain, rewriterule only needs if you really want to change domino, the same goes for ErrorDocument , in case it would just do this:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ /diretorio/administrador/$1 [R=301,L]

ErrorDocument 404 /diretorio/administrador/

Remember, the bar in front / indicates the root folder in redirects and ErrorDocument indicates the location of the file in your VirtualHost

    
10.11.2018 / 17:08