cancel
Showing results for 
Search instead for 
Did you mean: 

Website URL on CCGI servers

coolj
Dabbler
Posts: 23
Registered: ‎05-02-2011

Website URL on CCGI servers

Hi,
I've managed to set my domain and hostname to point to the CGI server such that www.eyemagine.co.uk displays the current image.html I've uploaded to the root of the server - not much point in trying it as the links on that page point to non-existent places, it's just a page to test it worked!  Ultimately, I'm going to upload Wordpress.
I have uploaded some images to url www.eyemagine.co.uk/imagery. ; When I enter that URL, it changes to www.eyemagine.co.uk/~coolj/imagery. ; Is there any way to stop this?  I'd prefer not to have my user name in the displayed URL on the browser.
thanks
Andrew
17 REPLIES 17
Peter_Vaughan
Community Veteran
Posts: 14,469
Registered: ‎30-07-2007

Re: Website URL on CCGI servers

C:\Documents and Settings\Peter>wget http://www.eyemagine.co.uk/imagery
--21:12:11--  http://www.eyemagine.co.uk/imagery
          => `imagery'
Resolving www.eyemagine.co.uk... done.
Connecting to www.eyemagine.co.uk[84.92.1.4]:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.eyemagine.co.uk/~coolj/imagery/ [following]
--21:12:11--  http://www.eyemagine.co.uk/%7Ecoolj/imagery/
          => `index.html'
Connecting to www.eyemagine.co.uk[84.92.1.4]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10,543 [text/html]
100%[====================================>] 10,543      332.13K/s
21:12:11 (332.13 KB/s) - `index.html' saved [10543/10543]

You appear to have a redirect in there somewhere. Do you have a .htaccess file in imagery which may be doing a redirect?
Are you using some king of CMS (content management system) or gallery system to create the pages. If so, it may be changing the URL.
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Website URL on CCGI servers

Hi Andrew,
That's caused by the trailing slash problem combined with the way ccgi is configured. You'll need a .htaccess file and you can find a recipe in the message linked from section 8 of the faq above.
Gabe
coolj
Dabbler
Posts: 23
Registered: ‎05-02-2011

Re: Website URL on CCGI servers

Thanks Guys.
Sorry for not responding to your help more quickly.  I checked and do not have a .htaccess file (ensuring that hidden files were being displayed.)  Having understood from your responses that something was being re-written and that I'd need to actually re-rewrite (!) it, then I needed to brush up on .htaccess and rewrite rules.  Rather than take the easy way out and just ask you what I should create, I've spent a little time trying to understand this...
I've come up with the following that I think will work and was hoping you might cast your eyes over it and let me know if I've understood correctly.
Because of suExec rewriting URLs with my username automatically (which is what Peter noticed) and Gabe spelt out in his post, then I need an .htaccess file to overcome it.
Here's my understanding:
www.eyemagine.co.uk/imagery/index.html is rewritten automatically to www.eyemagine.co.uk/~coolj/imagery/index.html
and so on for other resources, e.g.:
www.eyemagine.co.uk/~coolj/imagery/content/Johnson_040801_0320_large.html
I want to see in the browser, for example:
www.eyemagine.co.uk/imagery/index.html
www.eyemagine.co.uk/imagery/content/Johnson_040801_0320_large.html
that is, remove the ~coolj element.
so....
// make sure the Host is www.eyemagine.co.uk
RewriteCond %{HTTP_HOST} ^www\.eyemagine\.co\.uk$ [NC]
// make sure the resource starts with /~coolj/imagery/
RewriteCond %{REQUEST_URI} ^/~coolj/imagery/
// if the above two conditions match, then replace the part of the url that reads /~coolj/imagery/ with /imagery/[rest of URL]
RewriteRule /~coolj/imagery/(.*) /imagery/$1
It's the rewrite rule I'm not sure of.  Gabe's example in his post was rewriting a request to a root url to a subdirectory so having worked out how the rule was doing it, I came up with the above.
Now a slight complication, maybe, is that I want to put Wordpress on my CGI server so that the blog appears at www.eyemagine.co.uk (i.e. at the root) but I want to maintain my images at .../imagery/.  I've not checked yet, but presumably Wordpress is accessed with www.eyemagine.co.uk/index.html. ; My rules above won't affect this, so it's likely to get overwritten to www.eyemagine.co.uk/~coolj/index.html. ; I'm going to need additional rewrite rules to cope with that, which I'll do later.
Thanks for your help
Andrew
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Website URL on CCGI servers

Not quite. If you click on the first link in your last message, you'll notice it doesn't get rewritten. If you click on the second link in your first message, you'll notice it does. What you have there is a folder without a trailing slash, which is wrong and the server tries to fix it. What with suexec and another workaround on ccgi that was added to fix something else, the url ends up with not just the trailing slash appended but /~username added. We need to fix the trailing slash before it does that, and we can, using a .htaccess file with the recipe from the second example in the post linked from section 8 of the faq (where it talks about the trailing-slash problem). If you pop those lines straight after RewriteEngine on it should fix that problem.
Gabe
coolj
Dabbler
Posts: 23
Registered: ‎05-02-2011

Re: Website URL on CCGI servers

Thanks Gabe,
I think I get it, now you have pointed it out. 
The second example has a condition that checks to see if a request to a directory is being made.  The rewrite rule is looking for any characters from the beginning of the URL (at least 1) and that doesn't end with a "/" and remembers this string.  Then it rewrites that remembered string it with a "/" on the end.  I'm presuming that suExec hasn't rewritten anything by the time my .htaccess gets called so my rewrite will occur first and thus prevent it adding in the username and the final slash?
Andrew
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,370
Fixes: 75
Registered: ‎06-04-2007

Re: Website URL on CCGI servers

Yes, it's a module called later that fixes a missing trailing slash so the aim is to get in first and fix it using our own redirect. The subsequent module is then happy so doesn't do a further redirect.
David
David
coolj
Dabbler
Posts: 23
Registered: ‎05-02-2011

Re: Website URL on CCGI servers

Finally managed to get time to give it a go and it works a treat.
Thanks very much for all your help, appreciate it.
Regards
Andrew
BJepson
Grafter
Posts: 34
Registered: ‎15-08-2007

Re: Website URL on CCGI servers

HI,
I notice that Coolj's site still shows the ~username when accessed using a folder URL without a trailing slash eg www.eyemagine.co.uk/imagery .
I have also been tring to get this to work but I don't seem to be having any luck. I put this code in the top of the .htaccess
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R,L]

But it didn't make any difference.
Is it possible to get the combination of missing trailing slash and no ~username to work?
My site and affending URL is ccgi.jepnet.co.uk/scsc
Thanks
spraxyt
Superuser
Superuser
Posts: 10,063
Thanks: 1,370
Fixes: 75
Registered: ‎06-04-2007

Re: Website URL on CCGI servers

I assume the .htaccess for this is in the /scsc directory?
The problem is that within that .htaccess the URL to be matched will be an empty string so it *won't* match ^(.+[^/])$ (where at least one character must be present).
I fixed this by adding (what would be in your case) …

# Fix trailing slash problem
RewriteCond %{ENV:SCRIPT_URL} ^/~[^/]+
RewriteRule ^$ /scsc/ [R,L]

… rather than your current test.
David
David
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Website URL on CCGI servers

Quote from: BJepson
Is it possible to get the combination of missing trailing slash and no ~username to work?

Yes, but
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R,L]

should be
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R,L]

and goes in the / directory.
Gabe
BJepson
Grafter
Posts: 34
Registered: ‎15-08-2007

Re: Website URL on CCGI servers

Sorry for the confusion.  The htaccess is:

ErrorDocument 404 /error404.htm
RewriteEngine On
RewriteBase /
# fix the trailing slash for directorys
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R,L]

It is in the web root (htdocs) directory but it isn't working.  I can put a rewrite in each folder to detect the incorrect format and fix it there, but I'd prefer a generic solution.
Thanks
Brian
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Website URL on CCGI servers

Looks like that should work. (BTW, htdocs is on homepages.) Does the errordoc bit work? If not, have you saved as txt and uploaded as ascii and called it just .htaccess?
Gabe
BJepson
Grafter
Posts: 34
Registered: ‎15-08-2007

Re: Website URL on CCGI servers

Gabe,
Yes the .htaccess is in the root on the ccgi server (I spend so much time using Apache on other servers I always just think of htdocs).  The error document does work try http://ccgi.jepnet.co.uk/wibble .
I  have set up a more sophisticated test, making the rewrite divert to another folder to see if the match and the cond are actually working, but that also didn't work.
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ vault/ [R,L]

So either the rule match or the cond aren't working, or the trailing slash module is getting called before we get here
Brian..
Gabe
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Website URL on CCGI servers

If you move the errordoc line to the bottom, does it still work?
Gabe