Skip to content

Instantly share code, notes, and snippets.

@sinebeef
Last active July 3, 2020 22:56
Show Gist options
  • Save sinebeef/69ea623a85516294b4c64c7232730517 to your computer and use it in GitHub Desktop.
Save sinebeef/69ea623a85516294b4c64c7232730517 to your computer and use it in GitHub Desktop.
htaccess for blocking and stuff
# SSL FORCE
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# Block search bots
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} AltaVista [OR]
RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]
RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
RewriteCond %{HTTP_USER_AGENT} Slurp
RewriteRule ^.*$ "https\:\/\/domainz0r\.com" [R=301,L]
# Deny all IP except
<Limit GET POST>
order deny,allow
deny from all
allow from 127.0.0.1
</Limit>
# Better version
<FilesMatch "wp-login\.php|xmlrpc\.php">
Order allow,deny
Deny from all
</FilesMatch>
# Deny all IP access to file except
# wp-comments-post.php, xmlrpc.php, wp-login.php, wp-signup.php, wp-admin/admin.php, wp-admin/admin-ajax.php, wp-admin/admin-post.php
<Files wp-login.php>
Order deny,allow
deny from all
allow from 127.0.0.1
</Files>
# Redirect
Redirect 301 /old-page/ /new-page/
# https://wordpress.stackexchange.com/questions/359145/htaccess-modify-headers-if-url-ends-with-news/359151#359151
SetEnvIf Request_URI "feed/?$" APPLY_CORS
<If "-n reqenv('REDIRECT_APPLY_CORS')">
Header set X-Robots-Tag "noindex, nofollow"
</If>
<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment