.htaccess creation

pyrosember

Newbie
Joined
Oct 19, 2021
Messages
10
Reaction score
0
Hi, i'm trying to create a powerfull .htaccess to improve security and speed, although server needs to run some modules in php. I will share you my final htaccess to recieve advice from people who have more knowlegde about it than me.
 
Sure. Post the htaccess here. Will give u some recommendation if it can be optimised.
 
Here is the htaccess, i can't publish as code... I guess that it's because the character limits...
 
Last edited:
Here is the htaccess, i can't publish as code... I guess that it's because the character limits...
Paste it in pastebin and provide the link to that inside code tag.
You might have been blocked by BHW's malicious code detection algo (been there before).
 
buff, it was difficult...

http://pastie.org/p/2YU96iiQ79ZERAPfG78qWb
 
mostly htaccess is from https://gist.github.com/seoagentur-hamburg/c96bc796764baaa64d43b70731013f8a
 
hotlinking update for exceptions

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|webp)$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?dominio\. [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?facebook.com\. [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?twitter.com\. [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google.com\. [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?(other domains)\. [NC]
RewriteRule \.(gif|jpe?g?|png|webp)$ - [F,NC,L]
</ifModule>
 
oh... i almost forgot...

# errores not-found

ErrorDocument 400 domain/errors/bad-request.php
ErrorDocument 401 domain/errors/bad-request.php
ErrorDocument 403 domain/errors/denied-access.php
ErrorDocument 404 domain/errors/not-found.php
ErrorDocument 405 domain/errors/denied-access.php
ErrorDocument 408 domain/errors/timeout-access.php
ErrorDocument 500 domain/errors/server-error.php
ErrorDocument 502 domain/errors/bad-gateway.php
ErrorDocument 504 domain/errors/timeout-access.php
ErrorDocument 505 domain/errors/server-error.php
Redirect 301 / https://domain.com/


# errores End
 
Back
Top