Options Indexes FollowSymLinks ErrorDocument 404 /error404.html RewriteEngine On # rewrite any request to a unknown file to pmd-X.Y.Z # (or whatever subfolder the first rule will set to the environment variable PMD) # but redirect only if the file exists there RewriteRule .* - [E=PMD:pmd-5.0.1] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond /home/project-web/pmd/htdocs/%{ENV:PMD}%{REQUEST_URI} -f RewriteRule .* /%{ENV:PMD}%{REQUEST_URI} [L,R] # rewrite any remaining request to pmd-4.3.0 for backwards compatibility # as the old versions link to a non-versioned rule description URLs. RewriteCond /home/project-web/pmd/htdocs/pmd-4.3.0%{REQUEST_URI} -f RewriteRule .* /pmd-4.3.0%{REQUEST_URI} [L,R]