Skip to content

Instantly share code, notes, and snippets.

@BKeanu1989
Last active August 30, 2017 15:26
Show Gist options
  • Save BKeanu1989/6b69583f09dde95e52435120f4310d77 to your computer and use it in GitHub Desktop.
Save BKeanu1989/6b69583f09dde95e52435120f4310d77 to your computer and use it in GitHub Desktop.
apache redirects
SSL
www -> non-www
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
----- use this
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
----
-----------------------------
WP Only?
OLDDOMAIN -> NEWDOMAIN
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !.*YOURDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://YOURDOMAIN.com/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
-------
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
# real server configuration
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment