In regular expressions in . htaccess, what does this rule mean?

Asked

Viewed 53 times

0

What this rule is doing exactly?

 RewriteCond %{HTTP_HOST} ^(www\.)?website\.com\.br$   
 RewriteRule . - [E=REWRITEBASE:/]
  • I think it arrow the base of the URL, in your case, to / when the domain is that of the condition

  • But then it wouldn’t be RewriteBase /?

1 answer

1


The line of RewriteCond is a condition for the execution of the next line

The line of RewriteRule creates a variable with the name REWRITEBASE and value /, you can access it using %{ENV:REWRITEBASE}. Example of use:

RewriteCond %{HTTP_HOST} ^(www\.)?website\.com\.br$   
RewriteRule . - [E=REWRITEBASE:/website]

RewriteCond %{HTTP_HOST} ^(www\.)?other\.com\.br$   
RewriteRule . - [E=REWRITEBASE:/other]

RewriteRule ^(.*)$ %{ENV:REWRITEBASE}/$1

This way you can split hosting into folders for each registered domain

Browser other questions tagged

You are not signed in. Login or sign up in order to post.