On Sat, 27 Dec 2003 13:09:56 -0600 "Rodolfo J. Paiz" <rpaiz@xxxxxxxxxxxxxx> wrote:
> Note, however, that I am not searching for how to do this for the index > page... that works already and works well. What I'd like is to have my > "news" page, and have Apache search for news.php, news.html, or news.txt > (in that order) and serve up the first one it finds.
Someone already mentioned the rewriting rules which will work for you. Here is an example you can add to your httpd.conf:
RewriteEngine On RewriteRule (.*)\.html$ $1\.php [NC]
This will rewrite all URL's ending in html to php. The [NC] trailling parameter says to ignore case so ".HTML", ".hTmL" etc will be rewritten as well.
Sorry I hadn't posted anything in awhile, but Apache and I move veeeerrrryyy slowly. I know almost nothing about Apache other than how to quickly set up a VirtualHost, and in fact my first website ever (www.simpaticus.com) just started out around September of this year. So that's one reason.
The other is that I'm learning PHP and did not originally have the foresight to start naming my pages with ".php" as a suffix. Now I have a problem: the "Sendmail SMTP AUTH HOWTO" has (yay!) actually proven useful and got 600 visitors this December, and the page ends in ".html" and now what do I do? I can't rename it, or a bunch of people's links will break and Google will lose the page since the URL will change. So I'm investigating options:
1. mod_rewrite: Although I have not tested the rules suggested to me, this solution works. But I only change a page or two every week in my spare time, so if I used this approach then half my site would be out of commission for a long time until I got all pages switched. (Yes, I could rename them all quickly, but it was simplest to use the extension as an indicator of whether or not I'd worked on it yet.)
2. Content negotiation: I thought I could tell Apache to give all PHP files a score of 1, HTML files a score of 0.9, TXT files a score of 0.1, and then remove the extension from the URL when calling the page (i.e. sendmail-smtp-auth-howto instead of sendmail-smtp-auth-howto.html). With specific content negotiation for each page (the type-map files), this also works. However, it's more cumbersome and a lot of effort just for what I want. I have not found a way to tell Apache what score to assign to a PHP or HTML page /always/, which would allow me to drop in the PHP page when it was ready to take over the HTML. And there's one problem: this is a great solution for the future, but there would still be around 1,000 people and Google with broken links to the old URL.
3. Redirect Permanent. Functional in solving the current problem but perpetuates it somewhat. Quick and easy, though.
4. Create a redirect page, asking people to bookmark the new one and automatically going to the new one in 5 seconds. More work, but probably a better choice (and reusable!). Even if I need to redirect 10 or 12 pages, this will be transparent for users and Google. Over time, I will check the logs and see whether use of the old HTML variant is decreasing.
I have chosen to use Option #4. All I have to do is:
* Figure out how to get the requested URL from PHP somehow, so that I can then suggest the "correct" new URL to the visitor.
* Figure out how to get Apache to serve this page on any 404 "not found" error. Surely this is a single directive in the Apache docs somewhere and will be easy to find, I just haven't had time to look for it yet.
-- Rodolfo J. Paiz rpaiz@xxxxxxxxxxxxxx http://www.simpaticus.com
-- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list