Answer the question
In order to leave comments, you need to log in
htaccess regular expressions, how to select specific directories and redirect with QSA?
Gentlemen, help optimize .htaccess in such a way as to avoid duplicate RewriteRule for each of the folders.
I send the client the layout sources as a link to the technical subdomain, file listing is allowed in the rootOptions +Indexes
Options +Indexes
IndexOptions Charset=utf8
DirectoryIndex myindex.php
<IfModule mod_autoindex.c>
IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* XHTML HTMLtable SuppressHTMLPreamble
HeaderName /myFolder/.dirlist_src/dirlist_HEADER.html
ReadmeName /myFolder/.dirlist_src/dirlist_FOOTER.html
IndexIgnore .htaccess .ftpquota .DS_Store *.php *.zip *.htaccess
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/myFolder/(css|js|fonts|img)/(.*)$ [NC]
RewriteRule ^css(.+)$ /myFolder/.css$1 [QSA,L]
RewriteRule ^js(.+)$ /myFolder/.js$1 [QSA,L]
RewriteRule ^fonts(.+)$ /myFolder/.fonts$1 [QSA,L]
RewriteRule ^img(.+)$ /myFolder/.img$1 [QSA,L]
</IfModule>
if the URL /myFolder/{N}/ is requested, the link to /myFolder/{.2N} should be replaced (with a dot);
the rule “cuts off” part of the link with {N} and substitutes the rest to /myFolder/{.2N}, the url is not supplemented in any way and is formed with the parent request.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/myFolder/(css|js|fonts|img)/(.*)$ [NC]
RewriteRule ^css(.+)$ /myFolder/.css$1 [QSA,L]
RewriteRule ^js(.+)$ /myFolder/.js$1 [QSA,L]
RewriteRule ^fonts(.+)$ /myFolder/.fonts$1 [QSA,L]
RewriteRule ^img(.+)$ /myFolder/.img$1 [QSA,L]
</IfModule>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question