Changing Main Domain to Subfolder

Posted
Comments None

After being sidetracked for ages I am finally getting round to restyling this website.

But first I want to reorganise the directory structure so that it is more obvious what files and folders belong to Textpattern and to mirror my home web server setup. This will also have the advantage of making public_html less cluttered.

The first step is to create a new folder in public_html and to copy all my files and folders identified as belonging to Textpattern, including .htaccess, into this.

For the second step I now need to point my domain to this new folder. As it is the main domain the easiest way to do this is to replace the old .htaccess with one like this.

# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.

# Do not change this line.
RewriteEngine on

# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/

# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]

The redirect works perfectly.

The only trouble is Textpattern itself is causing a problem for me. It is working but, unfortunately, still pointing to the original folders. The only way to change the paths needed is to add the subfolder to the Site URL in preferences. This appends the subfolder to the route thus negating the redirect that I put in to avoid this in the first place.

So, for the time being, it’s back to the original setup and back to the drawing board.

Author
Categories

Comments

There are currently no comments on this article.

Add a comment

Enter your comment below. Fields marked * are required. You must preview your comment before submitting it.





← Older Newer →