Skip to content

Instantly share code, notes, and snippets.

@lukrizal
Last active August 29, 2015 14:13
Show Gist options
  • Save lukrizal/2bb4a9d1124f745a34d2 to your computer and use it in GitHub Desktop.
Save lukrizal/2bb4a9d1124f745a34d2 to your computer and use it in GitHub Desktop.
Left and Right bash prompt, proper htaccess redirection for non-ssl and non-ww, and nginx ssl
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect all non-ssl to ssl.
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect all non-www to www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
function prompt_right() {
echo -e "\033[0;36m\\\u\033[0m"
}
function prompt_left() {
echo -e "\033[0;35m\w\033[0m"
}
function prompt() {
compensate=5
PS1=$(printf "%*s\r%s\n\$ UPM > " "$(($(tput cols)+${compensate}))" "$(prompt_right)" "$(prompt_left)")
}
PROMPT_COMMAND=prompt
server {
listen 80;
server_name <domain_name>;
root <directory_path>;
set $siteName '<domain_name>';
location ~ \.php$ {
include fastcgi_params;
#fastcgi_pass 127.0.0.1:9001;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
#Prevent version info leakage
fastcgi_hide_header X-Powered-By;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\.ht {
deny all;
}
include /etc/nginx/conf.d/vhost-common.conf;
}
server {
listen 443;
server_name <domain_name>;
root <directory_path>;
set $siteName '<domain_name>-ssl';
include /etc/nginx/conf.d/vhost-common.conf;
ssl on;
ssl_certificate <cert_path>;
ssl_certificate_key <cert_key_path>;
location ~ \.php$ {
include fastcgi_params;
#fastcgi_pass 127.0.0.1:9001;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
#Prevent version info leakage
fastcgi_hide_header X-Powered-By;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment