Blog

Some useful and reusable htaccess rules


Force www redirect

# Force www. RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI}%{QUERY_STRING} RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI}%{QUERY_STRING}

Force HTTPS redirect

# Force HTTPS on all pages RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Domain Change

# Redirect to domain add.ph RewriteCond %{HTTP_HOST} !^add.ph$ RewriteCond %{HTTPS} off RewriteRule ^ http://add.ph/%{REQUEST_URI}?%{QUERY_STRING} [L,R=301] RewriteCond %{HTTP_HOST} !^add.ph$ RewriteCond %{HTTPS} on RewriteRule ^ https://add.ph/%{REQUEST_URI}?%{QUERY_STRING} [L,R=301] Note: replace add.ph with the new domain

Comments (0)


Add a Comment





Allowed tags: <b><i><br>Add a new comment:


A Few Accomplishments

Integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer non. Adipiscing cubilia elementum integer. Integer eu ante ornare amet commetus.

Possibly broke spacetime

Integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer adipiscing ornare amet.

Terraformed a small moon

Integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer adipiscing ornare amet.

Snapped dark matter in the wild

Integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer adipiscing ornare amet.

Contact Me

Integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer non. Adipiscing cubilia elementum integer. Integer eu ante ornare amet commetus.