Skip to content

Instantly share code, notes, and snippets.

@simbo1905
Last active February 13, 2018 08:10
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 simbo1905/f2ff8ead758faf9ed9e1f21ff3389cbc to your computer and use it in GitHub Desktop.
Save simbo1905/f2ff8ead758faf9ed9e1f21ff3389cbc to your computer and use it in GitHub Desktop.
.htaccess write traffic to a subfolder to move a site into a subfolder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/concrete575/
RewriteRule (.*) http://www.mysite.net/concrete575/$1 [R=301,L]
</IfModule>
@simbo1905
Copy link
Author

simbo1905 commented Feb 12, 2018

I was moving a concrete5 site installed into root ("/") onto a new hosted service where concrete5 was installed into a subfolder ("/concrete575").
This gist is a rewrite to send a 301 Moved Permanently to anything that doesn't have the prefix folder at the start of it.
The RewriteCond on line 4 matches request starting not with the subfolder because of the "!".
The RewriteRule captures the full path with (.*) and writes that as $1 at the end of the 301 redirect to the full site and path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment