Created
January 8, 2022 03:41
-
-
Save ozmos/c078133f35033c2606396c6dc9bf0463 to your computer and use it in GitHub Desktop.
Post install script to run on Wordpress on servers which use mode_cache.
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
#!/bin/bash | |
# 1. ensure .htaccess has correct re-write rule for index.php | |
if grep -F "$RewriteRule . /index.php [L]" .htaccess; then | |
echo "Default WP rewrite rule detected. \nChanging default WP rewrite rule" | |
sed -i 's/RewriteRule\ \. \/index\.php\ \[L\]/RewriteRule\ \^\(\.\*\)\$\ \/index\.php\/\$1\ \[L\]/' .htaccess | |
fi | |
if grep -F "$RewriteRule ^(.*)$ /index.php/\$1 [L]" .htaccess; then | |
echo "Default WP rewrite rule has been changed. Preventing WP from writing to .htaccess" | |
# 2. prevent wordpress from overwriting .htaccess | |
chmod 444 .htaccess; | |
ls -la .htaccess; | |
else | |
# 3. output error message if command fails | |
echo "Correct Rewrite rule not present. Please edit .htaccess manually and change permissions" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment