php - Apache Htaccess - Rewrite Rules Conflicts and/or Order -
i don't use .htaccess often, had setup local webserver , ended following rewrite rules:
# settings: general options +followsymlinks rewriteengine on rewritebase / # settings: protocol rewriterule ^ - [env=proto] rewritecond %{https} on rewriterule ^ - [env=proto:s] # remove www (https://www.example.com/ -> https://example.com/) rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule ^ http%{env:proto}://%1%{request_uri} [r=301,l] # versioning (main.20150826.css -> main.css) rewritecond %{request_filename} !-f rewriterule ^(.+)\.(\d+)\.(?:bmp|css|cur|gif|ico|jp(?:eg?|g)|js|png|svgz?|tiff?|webp)$ $1.$3 [l] # forbidden/missing resources (403 if directory/file starts '.') rewriterule (?:^|/)\. - [f] # missing resources (403 if file/directory not found) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^ - [f,l] # hotlinking prevention rewritecond %{http_referer} !^$ rewritecond %{request_filename} -f rewritecond %{request_filename} \.(?:bmp|cur|gif|ico|jp(?:eg?|g)|png|svgz?|tiff?|webp)$ [nc] rewritecond %{http_referer} !^https?://([^.]+\.)?domain\.tld [nc] rewriterule \.(?:bmp|cur|gif|ico|jp(?:eg?|g)|png|svgz?|tiff?|webp)$ - [nc,f,l]
since i'm not expert, know if have been placed in correct execution order , if there may conflict issues of them!
many in advance!
Comments
Post a Comment