Skip to content

Instantly share code, notes, and snippets.

@madeingnecca
Last active October 11, 2015 02:38
Show Gist options
  • Save madeingnecca/3790097 to your computer and use it in GitHub Desktop.
Save madeingnecca/3790097 to your computer and use it in GitHub Desktop.
APACHE utils
# Canonical host name for your website.
# THANKS DRUPAL7.
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# Redirect, way 1.
Redirect 301 /user/10 http://website.com/?action=users&id=10
# Redirect, way 2.
RewriteCond %{THE_REQUEST}% .*/user/10
RewriteRule ^(.*)$ http://website.com/?action=users&id=10 [R=301,L]
# Password generator.
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/mysite/.htpasswd
AuthGroupFile /dev/null
require valid-user
# Password generator, password:
# $ htpasswd -nb username newpassword
username:.USr4ePZMKA2k
# Handle non-php file.
# With mod_fcgi
AddHandler fcgid-script .svc
FCGIWrapper <ABSOLUTE_PATH>/.php-fcgi-starter .svc
# With mod_php
<IfModule mod_php5.c>
AddType application/x-httpd-php .svc
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment