cancel
Showing results for 
Search instead for 
Did you mean: 

Guide to creating seperate folders and clean URLs for your domains in CCGI space

tex
Grafter
Posts: 69
Registered: ‎30-07-2007

Guide to creating seperate folders and clean URLs for your domains in CCGI space

I came up with some .htaccess code that lets you point your domains to their own subdirectory within your CCGI space, e.g.
example.com/dir/file.php -> points to /files/home1/user/example/dir/file.php
ccgi.user.plus.com/another-file.php -> points to /files/home1/inspiration3/ccgi/another-file.php
This allows each of your websites to be unique and secure against XSS attacks. You can still link scripts between sites because only the URL is modified.
To set this up follow each step, you must have already turned on CCGI services and configured the DNS records of your new domain:

  • Move all your files from your ccgi space to a subfolder called "ccgi"

  • Create a new folder for your domain, i.e. if you have mysite.co.uk name the folder "mysite"

  • Create a file called ".htaccess" in your top level folder

  • Set the file contents to the following, replacing user with your username, folder with the name of the folder you created in step 2 and homeX with your plusnet assigned directory number:
    Quote
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ccgi\.user\.plus\.com$
    RewriteCond %{REQUEST_URI} ^(.+[^/])$
    RewriteCond /files/homeX/user/ccgi%1 -d
    RewriteRule (.+[^/])$ /$1/ [r=301,l]
    RewriteCond %{HTTP_HOST} ccgi\.user\.plus\.com$
    #RewriteCond %{REQUEST_URI} !^/ccgi
    RewriteRule ^(.*)$ /ccgi/$1
    RewriteCond %{HTTP_HOST} folder\.com$
    RewriteCond %{REQUEST_URI} ^(.+[^/])$
    RewriteCond /files/homeX/user/folder%1 -d
    RewriteRule (.+[^/])$ /$1/ [r=301,l]
    RewriteCond %{HTTP_HOST} folder\.com$
    #RewriteCond %{REQUEST_URI} !^/folder
    RewriteRule ^(.*)$ /folder/$1


  • Uncomment the highlighted lines if you need to support physical paths - in most cases you can leave this

  • Upload the .htaccess file

That's it! Remember to modify your scripts to use the new paths.
4 REPLIES 4
ffupi
Grafter
Posts: 370
Registered: ‎01-08-2007

Re: Guide to creating seperate folders and clean URLs for your domains in CCGI space

Not quite sure - would it be possible to get some more explanations.
As far as I understand it:
You have your URL ccgi.username.plus.com and a domain URL mydomain.com.
You want ccgi.username.plus.com to point into a directory1 and your mydomain.com to point into a directory2.
Both URLs point to the root of ccgi (the mydomain.com with appropriate settings in the PlusNet domain tool and by then asking Customer Support to do their bits as well).
And you put a .htaccess file into ccgi root.
Quote
RewriteEngine On
RewriteCond %{HTTP_HOST} ccgi\.username\.plus\.com$
RewriteCond %{REQUEST_URI} ^(.+[^/])$
RewriteCond /files/homeX/username/directory1%1 -d
RewriteRule (.+[^/])$ /$1/ [r=301,l]
RewriteCond %{HTTP_HOST} ccgi\.username\.plus\.com$
RewriteCond %{REQUEST_URI} !^/ccgi
RewriteRule ^(.*)$ /directory1/$1
RewriteCond %{HTTP_HOST} mydomain\.com$
RewriteCond %{REQUEST_URI} ^(.+[^/])$
RewriteCond /files/homeX/username/directory2%1 -d
RewriteRule (.+[^/])$ /$1/ [r=301,l]
RewriteCond %{HTTP_HOST} mydomain\.com$
RewriteCond %{REQUEST_URI} !^/mydomain
RewriteRule ^(.*)$ /directory2/$1

Do I understand this correct?

The reason I am asking, because I did search previously for a way to point URLs away from the root into directories and it works (trial and error):
Quote
RewriteEngine on
# mydomain.com
RewriteCond %{HTTP_HOST} ^mydomain.com$ [nc]
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]
# www.mydomain.com
RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [nc]
RewriteRule (.*) /directory2/$1


Is this any different in view of security to the way you have it in .htaccess?

Question 2:
Would you know how to point into a subdirectory, e.g. directory2/subdirectory ?
tex
Grafter
Posts: 69
Registered: ‎30-07-2007

Re: Guide to creating seperate folders and clean URLs for your domains in CCGI space

Yes you've understood correctly. You've also remembered to replace home1 in my example with whatever directory number plusnet has assigned you to (i.e. home1, home2 or home3) - I'll edit my post to mention this thanks.
My last and third from last lines of code for each section is the same as the method you're using. The middle line of code is not necessary - it's just there to support the physical site structure (i.e. to support badly coded javascripts and old links).
The first four lines of each part is needed to automatically append* a slash to directories. Without it Apache will redirect to the full path, e.g. example.com/mydir will become example.com/mydir/ instead of what would normally be example.com/example/mydir/
ffupi
Grafter
Posts: 370
Registered: ‎01-08-2007

Re: Guide to creating seperate folders and clean URLs for your domains in CCGI space

Quote from: A
...example.com/mydir will become example.com/mydir/ instead of what would normally be example.com/example/mydir/

Do I understand this correctly:
When I input into the browser
http://www.mydomain.com/subdirectory/
it will direct into
http://ccgi.username.plus.com/directory1/subdirectory
and display it as
http://www.mydomain.com/subdirectory
in the browser?
If this is the case, where in the .htaccess is the directory1->subdirectory to be put in?
Thanks
tex
Grafter
Posts: 69
Registered: ‎30-07-2007

Re: Guide to creating seperate folders and clean URLs for your domains in CCGI space

Quote from: ffupi
If this is the case, where in the .htaccess is the directory1->subdirectory to be put in?
You just need to change the folder part in the code of my first post.