Skip to content

Instantly share code, notes, and snippets.

@pejicbgd
Last active August 29, 2015 14:06
Show Gist options
  • Save pejicbgd/9c1415914031250a64a4 to your computer and use it in GitHub Desktop.
Save pejicbgd/9c1415914031250a64a4 to your computer and use it in GitHub Desktop.
Simple htacces file that redirects to subfolder
<IfModule mod_rewrite.c>
RewriteEngine on
# make sure directory listing is disabled
Options +FollowSymLinks -Indexes
# Use either Cond 1 or Cond 2, or neither, if your host is localhost
# Cond 1: rewrite www.example.com to example.com" uncomment these
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Cond 2: To rewrite example.com to www.example.com" uncomment these
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# redirect all to subfolder
RewriteRule ^$ subfolder/ [L]
RewriteRule (.*) subfolder/$1 [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment