Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Created November 28, 2014 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxfight3r/838dbc4b1464615a016c to your computer and use it in GitHub Desktop.
Save tuxfight3r/838dbc4b1464615a016c to your computer and use it in GitHub Desktop.
apache vhost url redirection tricks
#Redirect NonSSL to SSL
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#Redirect if the host name not begins with WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.nerdplanet.co.uk$ [NC]
RewriteRule ^(.*)$ https://www.nerdplanet.co.uk$1 [R=301]
#Redirect if the request uri deosnt end with a /
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
#Apache redirects
Redirect permanent /test http://test.nerdplanet.co.uk/~test/
Redirect temp /test http://test.nerdplanet.co.uk/~test/
Redirect seeother /test http://test.nerdplanet.co.uk/~test/
Redirect gone /test
(OR)
Redirect 301 /test http://test.nerdplanet.co.uk/~test/
Redirect 302 /test http://test.nerdplanet.co.uk/~test/
Redirect 303 /test http://test.nerdplanet.co.uk/~test/
Redirect 410 /test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment