Renato Dinhani
Renato Dinhani

Reputation: 36676

How do these htaccess rules work?

I was instructed to put these rules in my .htaccess file to redirect the request of my website to a sub-directory without adding the sub-directory in the URL, but I can't understand how these rules are working. Can someone explain to me?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?dinhani.com.br$ [NC]
RewriteCond %{REQUEST_URI} !^/dinhani/
RewriteRule ^(.*)$ /dinhani/$1

Upvotes: 0

Views: 45

Answers (1)

Marc B
Marc B

Reputation: 360602

In pseudo-code:

if ($HTTP_HOST is NOT dinhani.com.br NOR www.dinhani.com.br, doing case-insensitive comparisons) {
    if ($REQUEST_URI does NOT start with /dinhani/) {
        change requested URL into /dinhani/original_request_url_here
    }
}

Upvotes: 1

Related Questions