Skip to content

Instantly share code, notes, and snippets.

@saxenap
Last active August 29, 2015 13:59
Show Gist options
  • Save saxenap/10741490 to your computer and use it in GitHub Desktop.
Save saxenap/10741490 to your computer and use it in GitHub Desktop.
#!/bin/bash
###############################################
# To use:
# wget https://gist.githubusercontent.com/saxenap/10741490/raw
# chmod 777 raw
# ./raw
###############################################
echo "" >> /etc/httpd/conf/httpd.conf
echo "" >> /etc/httpd/conf/httpd.conf
echo "*****************************************"
echo "*****************************************"
echo " 1. Set Default Charset"
echo "*****************************************"
echo "AddDefaultCharset UTF-8" >> /etc/httpd/conf/httpd.conf
echo "*****************************************"
echo "*****************************************"
echo " 2. Set isJsonInUrl to True if .json in URL"
echo "*****************************************"
echo "SetEnvIf Request_URI \"\.json$\" isJsonInUrl=TRUE" >> /etc/httpd/conf/httpd.conf
echo "*****************************************"
echo "*****************************************"
echo " 3. Set Macro"
echo "*****************************************"
echo "" >> /etc/httpd/conf/httpd.conf
echo "<Macro Resources \$resourceName>" >> /etc/httpd/conf/httpd.conf
echo " <LocationMatch /beta/\$resourceName>" >> /etc/httpd/conf/httpd.conf
echo " RewriteEngine On" >> /etc/httpd/conf/httpd.conf
echo " RewriteCond %{REQUEST_METHOD} ^(GET|POST|PUT)" >> /etc/httpd/conf/httpd.conf
echo " RewriteRule / /main/controllers/\$resourceName.php [L,QSA]" >> /etc/httpd/conf/httpd.conf
echo "" >> /etc/httpd/conf/httpd.conf
echo " RewriteCond %{REQUEST_METHOD} ^(GET|POST|PUT)" >> /etc/httpd/conf/httpd.conf
echo " RewriteRule ([0-9:\-]{1,7}) /index.php?resource=%1_single_\$resourceName&id=$1 [L,QSA]" >> /etc/httpd/conf/httpd.conf
echo " </LocationMatch>" >> /etc/httpd/conf/httpd.conf
echo "</Macro>" >> /etc/httpd/conf/httpd.conf
echo "Use Resources users" >> /etc/httpd/conf/httpd.conf
echo "UndefMacro Resources" >> /etc/httpd/conf/httpd.conf
echo "" >> /etc/httpd/conf/httpd.conf
echo "" >> /etc/httpd/conf/httpd.conf
echo "*****************************************"
echo "*****************************************"
echo " 4. Hide Server Information"
echo "*****************************************"
echo "" >> /etc/httpd/conf/httpd.conf
echo "<IfModule mod_rewrite.c>" >> /etc/httpd/conf/httpd.conf
echo " Header set X-XSS-Protection "1; mode=block"" >> /etc/httpd/conf/httpd.conf
echo " Header set X-Content-Type-Options: nosniff" >> /etc/httpd/conf/httpd.conf
echo " Header unset X-Powered-By" >> /etc/httpd/conf/httpd.conf
echo " #RewriteRule ^/elb_heath_check.php$ /elb_heath_check.php [L]" >> /etc/httpd/conf/httpd.conf
echo " #RewriteCond %{DOCUMENT_ROOT}/%{SCRIPT_FILENAME} -f" >> /etc/httpd/conf/httpd.conf
echo " #RewriteRule ^(.*)$ /$1 [L,QSA]" >> /etc/httpd/conf/httpd.conf
echo "</IfModule>" >> /etc/httpd/conf/httpd.conf
echo "" >> /etc/httpd/conf/httpd.conf
echo "" >> /etc/httpd/conf/httpd.conf
echo "*****************************************"
echo "*****************************************"
echo " 5. Restart Apache Server"
echo "*****************************************"
sudo service httpd restart
echo "*****************************************"
echo "*****************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment