After 8 years with the same Apache webserver, the .htaccess file seems to be a bit heterogeneous. I have taken some care about readability, but there are still some problems (such as pages with www. prefix not working). How would you improve this .htaccess?
RewriteEngine on
ErrorDocument 404 /404/
# RENAME MYWEB
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$
RewriteRule ^/?projects/web - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$
RewriteRule ^(.*?)/?$ /projects/web/$1 [NC,L]
# RENAME WEB1
RewriteCond %{HTTP_HOST} ^(www.)?web1.myweb.com$
RewriteRule ^/?projects/web1 - [L]
RewriteCond %{HTTP_HOST} ^(www.)?web1.myweb.com$
RewriteRule ^(.*?)/?$ /projects/web1/$1 [NC,L]
# RENAME WEB2
RewriteCond %{HTTP_HOST} ^(www\.)?web2\.myweb\.com$ [NC]
RewriteRule ^(.*)$ /projects/web2/$1 [NC,QSA,L]
# RENAME WEB3
RewriteCond %{HTTP_HOST} ^(www\.)?web3\.myweb\.com$
RewriteRule ^/?projects/web3 - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?web3\.myweb\.com$
RewriteRule ^(.*?)/?$ /projects/web3/$1 [NC,L]
# RENAME WEB4
RewriteCond %{HTTP_HOST} ^(www\.)?web4\.myweb\.com$ [NC]
RewriteRule ^(.*)$ /projects/web4/$1 [NC,QSA,L]
# RENAME WEB5
RewriteCond %{HTTP_HOST} ^(www\.)?web5\.myweb\.com$
RewriteRule ^/?projects/web5 - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?web5\.myweb\.com$
RewriteRule ^(.*?)/?$ /projects/web5/$1 [NC,L]
# ALLOW HTTPS ONLY AT TELEGRAM BOTS
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !projects/bot1/index.php$ [NC]
RewriteCond %{REQUEST_URI} !projects/bot2/index.php$ [NC]
RewriteCond %{REQUEST_URI} !projects/bot3/index.php$ [NC]
RewriteCond %{REQUEST_URI} !projects/bot4/index.php$ [NC]
RewriteCond %{REQUEST_URI} !logan/bot5/index.php$ [NC]
RewriteRule ^/?(.*)$ http://%{SERVER_NAME}/$1 [R,L]
# SHORTCUTS
RewriteRule ^favicon.ico$ res/favicon.ico [NC]
RewriteRule ^robots.txt$ res/robots.txt [NC]
RewriteRule ^enter/(.*)$ res/enter/$1 [NC]
RewriteRule ^logout/(.*)$ res/logout/$1 [NC]
# DEFAULT: CUSTOM DIRECTORY LISTING
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/404/?$
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteRule ^(.*)/$ /index.php?path=$1
I can provide more detail about the format and behaviour of the pages if needed.
Usually, I test my .htaccess using this htaccess tester and manually checking it out.