Forum Moderators: phranque
One solution is to declare all subdomains as ServerAliases of the main domain or point them all to the same DocumentRoot, and then use mod_rewrite to 'sort them all out' into their own individual filespaces as needed, or into a common filespace as required. This can be accomplished by using RewriteCond to test the HTTP_HOST variable to get the requested hostname and act upon its value.
But it's impossible to recommend a solution, not knowing the actual problem.
Jim
We're launching a new News section on our website managed by one CMS that outputs static HTML pages.
This News section will be published to www.example.org/news/ and a sample story URI might be /news/2007/08/28/sample/index.html.
We also need a paginated series of index pages that list the last 20 stories published to the News section. While the same CMS could produce these index pages, over time they would add up in the hundreds (or possibly thousands) since we'll be publishing a number of news stories each day. While this isn't necessarily a problem per se, we have an another option.
We have a blog at gristmill.example.org, which is powered by a second CMS. This is a dynamic site and we use it to power commenting on the statically generated website. We do this by auto-publishing dummy stories to the second CMS and then embedding the comment threads into the static HTML pages. Because we're doing this already, the second CMS is already generating an index page at gristmill.example.org/section/news.
But the desire is to have the URL of the News index page to be www.example.org/news/ without browser redirection.
And yes, I can edit our apache conf files.
[edited by: jdMorgan at 3:10 pm (utc) on Aug. 28, 2007]
[edit reason] No URLs, please. See Terms of service. [/edit]
From lowest level to highest, here are the ones that come to mind:
Be on the lookout for problems with file permissions, cookies, sessions, user authorization, and SSL while working on this.
Jim
Also, while the long term plan is to have one website (rather than a website and a blog) managed by one CMS, combining the subdomain and domain is not an option at this time.
Thus, it looks like the only viable option (of the ones discussed thus far) is mod_proxy, but I'm not crazy about the tracking and performance issues that you mentioned.
I suppose I could employ the same technique that I'm using to allow commenting on static pages, which involves embedding some Perl in the HTML that gets and prints content using LWP::UserAgent.
Alias directiveThe Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot. URLs with a (%-decoded) path beginning with url-path will be mapped to local files beginning with directory-filename.
I believe you may find the Alias [httpd.apache.org] directive entirely adequate for your application, as long as you don't have any of the complicating issues with permissions, cookies, etc. previously mentioned. Alternatively, the AliasMatch directive offers the more sophisticated regular-expressions matching of requested URL-paths, rather than the simple prefix-matching used by Alias.
Jim
Again, the index page (gristmill.example.org/section/news) is dynamically generated. And I just realized it is actually gristmill.example.org/?op=section§ion=news. The CMS obviously employs its own rewriting.
So, I added the following to my conf file (for www.example.org):
AliasMatch /news$ http://gristmill.example.org/section/news
But upon testing resulted in a 404 with the following message in the error log:
File does not exist: http://gristmill.example.org/section/news
I expected this as there is no file to map to.
What am I missing?
Thanks again for all your help.
[edited by: jdMorgan at 7:09 pm (utc) on Aug. 29, 2007]
[edit reason] example.org. [/edit]
It matters not one bit that this file is a CMS script. It lives in the server filesystem, and should be accessible there. Your main challenge is to find it, because in my example, "/httpd/grist/www/" is a made-up path. The path to the script should be easy to construct, as it will be based on the path declared as DocumentRoot for the 'main' domain.
Jim
Once that penny dropped, it became very easy to have a URL system that was search engine friendly, and was structured completely different to the file structure on the server itself.