Last active
March 9, 2022 10:03
-
-
Save bentideswell/fd18fd4e1391071b10b5edcb34c2b4d6 to your computer and use it in GitHub Desktop.
IP Protection for WordPress in a subdirectory when using local integration mode in FishPig_WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Secure WordPress when integrated into Magento when installed in a subdirectory | |
# https://fishpig.co.uk/magento/wordpress-integration/docs/#security | |
# | |
# | |
# Setup the default index file | |
DirectoryIndex index.html index.php | |
<IfModule mod_rewrite.c> | |
# | |
# Enable Rewrites | |
RewriteEngine On | |
# | |
# Allow HTTP Auth | |
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
# | |
# Set WordPress subdirectory | |
# The value entered below will need to be set throughout this document in several places | |
RewriteBase /wp/ | |
# | |
# Standard WordPress rewrites | |
# You will need to change /wp/ below to match the RewriteBase entered above | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /wp/index.php [L] | |
# | |
# Allow access to certain file extensions | |
RewriteCond %{REQUEST_URI} !\.(js|css|jpg|png|gif|svg|woff|woff2)$ | |
# | |
# Allow access to specific PHP files | |
RewriteCond %{REQUEST_URI} !^$ | |
RewriteCond %{REQUEST_URI} !/index.php | |
# | |
# Change /wp/ to match the RewriteBase value above | |
RewriteCond %{REQUEST_URI} !^/wp/$ | |
# | |
# Remove this line if you don't use comments | |
RewriteCond %{REQUEST_URI} !/wp-comments-post.php | |
# | |
# Some plugins use admin-ajax.php | |
# If none of your plugins use this file | |
# Remove the line below to block access to it | |
RewriteCond %{REQUEST_URI} !/wp-admin/admin-ajax.php | |
# | |
# Allow global access to specific IPs | |
# This will allow Admin access | |
# Enter IPs below that should be allowed Admin access | |
# RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$ | |
# RewriteCond %{REMOTE_ADDR} !^82\.12\.10\.1$ | |
# | |
# This line allows Admin access to all IPs | |
# Remove this to limit it to the IPs entered above | |
RewriteCond %{REQUEST_URI} !/wp-admin/ | |
RewriteCond %{REQUEST_URI} !/wp-login.php | |
# | |
# Rewrite to 404.php | |
# You can create a 404.php file in your WordPress folder | |
# If this file doesn't exist, the Magento 404 will display | |
RewriteRule .* 404.php [L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment