Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
RESTful services (cgi,php) and mod_rewrite
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- RESTful services (cgi,php) and mod_rewrite
RESTful services (cgi,php) and mod_rewrite
17-07-2011 1:20 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Hello to all !
I have spent some time reading the forum and researching articles relating to mod_rewrite, .htaccess etc. I am a little clearer about how to use these 2 'functions' and in relation to Plusnet webspace, but I need some help just pulling it all together to clarify if the subject of this post/topic is possible.
Motivation:
I want to be able to present RESTful/user friendly URLs to access website file/pages and to any scripts that dynamically generate pages, whilst keeping a consistent url domain (i.e. no redirects). I hope that makes sense
Observations:
re: default plusnet web space(s): www.username.plus.com ; and ccgi.username.plus.com
I have sorted (i think) being able process user friendly url's, via mod_rewrite, so that the physical file in the same webspace is returned and the domain url is consistent (for want of a better phrase).
e.g. www.username.plus.com/docs/0001 ; rewritten to www.username.plus.com/documents/physicaldoc1.html produces the output without affecting the url ie. it remains consistent.
However, I cannot do this if I am 'rewriting' to the ccgi webspace to dynamically process a user friendly url via a script without a redirect happening and the domain url keeping consistent.
e.g. www.username.plus.com/docs/0001 ; rewritten to ccgi.username.plus.com/cgi-bin/getdoc.php?id=0001
If possible I would like to keep the site based on the www.username.plus.com web space, but I am wondering if the only way is to port it all to the ccgi server....... which is not recommended.
As an aside, I could include using a script e.g. php to act as a controller/despactcher for processing all user-friendly url's dynamically, IF it is possible to stop the apparent domain redirects.
I hope this is written well enough to understand. Please if any one has any suggestions for solutions, do reply. Or if I have been remiss then let me know how and what I need to do to put it right.
Thank you
Chris
I have spent some time reading the forum and researching articles relating to mod_rewrite, .htaccess etc. I am a little clearer about how to use these 2 'functions' and in relation to Plusnet webspace, but I need some help just pulling it all together to clarify if the subject of this post/topic is possible.
Motivation:
I want to be able to present RESTful/user friendly URLs to access website file/pages and to any scripts that dynamically generate pages, whilst keeping a consistent url domain (i.e. no redirects). I hope that makes sense

Observations:
re: default plusnet web space(s): www.username.plus.com ; and ccgi.username.plus.com
I have sorted (i think) being able process user friendly url's, via mod_rewrite, so that the physical file in the same webspace is returned and the domain url is consistent (for want of a better phrase).
e.g. www.username.plus.com/docs/0001 ; rewritten to www.username.plus.com/documents/physicaldoc1.html produces the output without affecting the url ie. it remains consistent.
However, I cannot do this if I am 'rewriting' to the ccgi webspace to dynamically process a user friendly url via a script without a redirect happening and the domain url keeping consistent.
e.g. www.username.plus.com/docs/0001 ; rewritten to ccgi.username.plus.com/cgi-bin/getdoc.php?id=0001
If possible I would like to keep the site based on the www.username.plus.com web space, but I am wondering if the only way is to port it all to the ccgi server....... which is not recommended.
As an aside, I could include using a script e.g. php to act as a controller/despactcher for processing all user-friendly url's dynamically, IF it is possible to stop the apparent domain redirects.
I hope this is written well enough to understand. Please if any one has any suggestions for solutions, do reply. Or if I have been remiss then let me know how and what I need to do to put it right.
Thank you
Chris
Message 1 of 4
(1,565 Views)
3 REPLIES 3
Re: RESTful services (cgi,php) and mod_rewrite
20-07-2011 8:59 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Hi Chris,
No, if I interpret you correctly then you're right, you can't fake the domain with a rewrite. If you were prepared to filter out older browsers and give them a less friendly alternative, then you could use CORS and AJAX the content off ccgi, but I think it would be easier just to move your site onto ccgi and repoint the domain.
Gabe
No, if I interpret you correctly then you're right, you can't fake the domain with a rewrite. If you were prepared to filter out older browsers and give them a less friendly alternative, then you could use CORS and AJAX the content off ccgi, but I think it would be easier just to move your site onto ccgi and repoint the domain.
Gabe
Message 2 of 4
(364 Views)
Re: RESTful services (cgi,php) and mod_rewrite
22-07-2011 9:37 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Thanks for the clarification Gabe; it is as I thought then 
I can guess at some reasons why the webspace servers were set up this way, but it is disappointing none the less - as its such a 'small' step to open up some nice possibilities (for me anyway).
Thanks again.
Chris

I can guess at some reasons why the webspace servers were set up this way, but it is disappointing none the less - as its such a 'small' step to open up some nice possibilities (for me anyway).
Thanks again.
Chris
Message 3 of 4
(364 Views)
Re: RESTful services (cgi,php) and mod_rewrite
22-07-2011 4:16 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
It's not to do with the way the webserver is set up, it's how mod_rewrite works.
mod_rewrite can only keep the URL the same if it can fetch the file it needs to fulfil the request from it's own storage. An url on another server is not in it's storage, so it can't get the data it needs to send back to the client, and as a result it redirects the client to that resource instead.
From http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule:
To be able to present data from another server and preserve the URL you'd need to use something like mod_proxy, which on a shared platform is just too risky to enable.
mod_rewrite can only keep the URL the same if it can fetch the file it needs to fulfil the request from it's own storage. An url on another server is not in it's storage, so it can't get the data it needs to send back to the client, and as a result it redirects the client to that resource instead.
From http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule:
Quote If an absolute URL is specified, mod_rewrite checks to see whether the hostname matches the current host. If it does, the scheme and hostname are stripped out and the resulting path is treated as a URL-path. Otherwise, an external redirect is performed for the given URL.
To be able to present data from another server and preserve the URL you'd need to use something like mod_proxy, which on a shared platform is just too risky to enable.
Message 4 of 4
(364 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- RESTful services (cgi,php) and mod_rewrite