Skip to content

Instantly share code, notes, and snippets.

@johnbocook
Last active September 28, 2017 07:04
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 johnbocook/38098ba6712e7318c9e0a69eaae8052c to your computer and use it in GitHub Desktop.
Save johnbocook/38098ba6712e7318c9e0a69eaae8052c to your computer and use it in GitHub Desktop.
htaccess stuff
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301]
RedirectMatch 301 ^/blog/(.*)$ http://blog.example.com/$1
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>
Options +FollowSymLinks
RewriteEngine on
#========================================================================
# FIRST Handle the http requests first before removing the additional url junk
#========================================================================
#rule for graffiticaps.com to link to one directory
RewriteCond %{HTTP_HOST} ^(www.)?graffiticaps.com$
RewriteCond %{REQUEST_URI} !^/one/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /one/$1
#rule for usacapinc.com to link to two directory. Its the same as above just with usacapinc.com URL and subfolder
RewriteCond %{HTTP_HOST} ^(www.)?usacapinc.com$
RewriteCond %{REQUEST_URI} !^/two/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /two/$1
#==========================================================
# SECOND Remove the additional url junk once the new url is loaded
#==========================================================
#rule for graffiticaps.com url rewrite to remove /one/index.php from the URL
RewriteCond %{HTTP_HOST} ^(www.)?graffiticaps.com$
RewriteRule ^(/)?$ one/index.php
#rule for usacapinc.com url rewrite to remove /two/index.php from the URL. Again its the same as above just with the usacapinc.com URL and sub folder info.
RewriteCond %{HTTP_HOST} ^(www.)?usacapinc.com$
RewriteRule ^(/)?$ two/index.php
RewriteEngine On
RewriteCond %{HTTP_HOST} !^yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
## Blocks direct access to wp-comments.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post.php*
RewriteCond %{HTTP_REFERER} !.*yourdomainname.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment