Example: a feature of redirection on synonyms.


Suppose there is a domain domain1.tld and a synonym domain2.tld. If you request the address in the browserhttp://domain2.tld/dir / with a slash sign at the end, the index page from the dir directory of the main domain will be displayed, while the contents of the browser address bar will remain unchanged. But if you request http://domain2.tld/dir without a slash at the end, then redirection to will occurhttp://domain1.tld/dir /, and the contents of the address bar will change accordingly.


This is a feature of the mod dir module, in which if there is a request for a file that is a directory, but the request does not end with a slash sign, then mod_dir performs an external redirect to the same address with a slash sign at the end. In the case of a synonym, the domain name is also replaced during redirection. If this behavior of the web server does not suit you, add the following lines to the .htaccess file:


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !^domain2.tld$
RewriteRule ^(.+[^/])$ http://domain2.tld/$1/ [R]