PHP include and changing page names

PHP include and changing page names

am 11.11.2007 21:45:27 von Ed Mullen

I'm considering using PHP to include the menus on my Web pages. I've
tested it and it works fine (even though I know next to nothing about
PHP). My understanding is that the page that will import content using
a PHP include must have a .PHP extension. Which means that all my page
names (which now end in .html) will change. Which means that the search
engine results will point to non-existent pages.

Any thoughts on what I might do about this dilemma?

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
Why are there interstate highways in Hawaii?

Re: PHP include and changing page names

am 11.11.2007 22:13:08 von Safalra

On Sun, 11 Nov 2007 15:45:27 -0500, Ed Mullen wrote:
> I'm considering using PHP to include the menus on my Web pages. I've
> tested it and it works fine (even though I know next to nothing about
> PHP). My understanding is that the page that will import content using
> a PHP include must have a .PHP extension. Which means that all my page
> names (which now end in .html) will change. Which means that the search
> engine results will point to non-existent pages.


Does your host allow you to use .htaccess files? If they do, you can either
allow PHP to process .html files, or use URL rewriting. If using the second
option, consider rewtiting URLs to end with a slash and then internally map
to the correct script - this hides the technology from the user and allows
it to change at a later date without complication.


If you can't use .htaccess, one trick to to take advantage of the rules
most servers use by default, and for each URL of the form:

http://www.example.com/somewhere/something.html

....replace the HTML file with a PHP file here:

http://www.example.com/somewhere/something.html/index.php

....where 'something.html' is now a directory.


--
Safalra (Stephen Morley)

The 'white-space' Property In CSS:
http://www.safalra.com/web-design/css/white-space-property/

Re: PHP include and changing page names

am 11.11.2007 22:35:25 von dorayme

In article ,
Ed Mullen wrote:

> I'm considering using PHP to include the menus on my Web pages. I've
> tested it and it works fine (even though I know next to nothing about
> PHP). My understanding is that the page that will import content using
> a PHP include must have a .PHP extension. Which means that all my page
> names (which now end in .html) will change. Which means that the search
> engine results will point to non-existent pages.
>
> Any thoughts on what I might do about this dilemma?

On servers that you can control, you can make them check and
process for php on .html ages, either directly in config files or
via .htaccess. On servers that you do not control or do not allow
..htaccess control of this, you can ask the server admin to fix it
so that all your .html files are scanned for php.

If they will not allow this (there are some downsides, one being
servers have to work harder and less efficiently, not all html
files have php and it is wasting its time) you can ask them to
redirect all .html files to php mirror files which you can make
and put on the server to avoid having to upset already bookmarked
html files etc.

All these options I have done for different sites and purposes.
On one, I just have decided to use .php and be done (simple!).

--
dorayme

Re: PHP include and changing page names

am 11.11.2007 23:16:01 von lws4art

Ed Mullen wrote:
> I'm considering using PHP to include the menus on my Web pages. I've
> tested it and it works fine (even though I know next to nothing about
> PHP). My understanding is that the page that will import content using
> a PHP include must have a .PHP extension. Which means that all my page
> names (which now end in .html) will change. Which means that the search
> engine results will point to non-existent pages.

The include file doesn't but the calling file may for it to parse PHP,
server settings dependent.


....

But it is advisable to make the include file fileWithPhpCode.php so if
some hacker call your file directly they will only see the html output
not the php source.

>
> Any thoughts on what I might do about this dilemma?
>

Very simple example...
..htaccess file

RewriteEngine On

RewriteRule ^(.*)\.html$ $1.php

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Re: PHP include and changing page names

am 12.11.2007 05:50:33 von Ed Mullen

Jonathan N. Little wrote:
> Ed Mullen wrote:
>> I'm considering using PHP to include the menus on my Web pages. I've
>> tested it and it works fine (even though I know next to nothing about
>> PHP). My understanding is that the page that will import content
>> using a PHP include must have a .PHP extension. Which means that all
>> my page names (which now end in .html) will change. Which means that
>> the search engine results will point to non-existent pages.
>
> The include file doesn't but the calling file may for it to parse PHP,
> server settings dependent.
>
>
> > ...
>
> But it is advisable to make the include file fileWithPhpCode.php so if
> some hacker call your file directly they will only see the html output
> not the php source.
>
>>
>> Any thoughts on what I might do about this dilemma?
>>
>
> Very simple example...
> .htaccess file
>
> RewriteEngine On
>
> RewriteRule ^(.*)\.html$ $1.php
>

Excellent. Thank you all. I do have the ability to edit the .htaccess
file. I will go read more so as not to be quite as dangerous as I am now.

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
Introducing LITE - the new way to spell LIGHT with 20% fewer letters!

Re: PHP include and changing page names

am 12.11.2007 07:47:14 von Ed Mullen

Ed Mullen wrote:
> Jonathan N. Little wrote:
>> Ed Mullen wrote:
>>> I'm considering using PHP to include the menus on my Web pages. I've
>>> tested it and it works fine (even though I know next to nothing about
>>> PHP). My understanding is that the page that will import content
>>> using a PHP include must have a .PHP extension. Which means that all
>>> my page names (which now end in .html) will change. Which means that
>>> the search engine results will point to non-existent pages.
>>
>> The include file doesn't but the calling file may for it to parse PHP,
>> server settings dependent.
>>
>>
>> >> ...
>>
>> But it is advisable to make the include file fileWithPhpCode.php so if
>> some hacker call your file directly they will only see the html output
>> not the php source.
>>
>>>
>>> Any thoughts on what I might do about this dilemma?
>>>
>>
>> Very simple example...
>> .htaccess file
>>
>> RewriteEngine On
>>
>> RewriteRule ^(.*)\.html$ $1.php
>>
>
> Excellent. Thank you all. I do have the ability to edit the .htaccess
> file. I will go read more so as not to be quite as dangerous as I am now.
>

Well, that was interesting.

Using the above RewriteRule I did a test. And the only way it works is
if I rename the calling .html file to .shtml. Which, obviously, defeats
the purpose.

Is this something that can configured/over-ridden using the .htaccess
file? Or is it at the server configuration level (which I do not have
access to)?

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
There are a number of mechanical devices which increase sexual arousal,
particularly in women. Chief among these is the Mercedes-Benz 380SL.

Re: PHP include and changing page names

am 12.11.2007 07:55:17 von dorayme

In article ,
Ed Mullen wrote:

>
> Is this something that can configured/over-ridden using the .htaccess
> file? Or is it at the server configuration level (which I do not have
> access to)?

Server admins can block all your attempts. I had a case of this
recently and the Uni concerned offered the back-up plan I
mentioned in my previous post (to direct all .html to mirror .php
ones)...

--
dorayme

Re: PHP include and changing page names

am 12.11.2007 15:27:45 von lws4art

Ed Mullen wrote:
> Ed Mullen wrote:
>> Jonathan N. Little wrote:
>>> Ed Mullen wrote:
>>>> I'm considering using PHP to include the menus on my Web pages.
>>>> I've tested it and it works fine (even though I know next to nothing
>>>> about PHP). My understanding is that the page that will import
>>>> content using a PHP include must have a .PHP extension. Which means
>>>> that all my page names (which now end in .html) will change. Which
>>>> means that the search engine results will point to non-existent pages.
>>>
>>> The include file doesn't but the calling file may for it to parse
>>> PHP, server settings dependent.
>>>
>>>
>>> >>> ...
>>>
>>> But it is advisable to make the include file fileWithPhpCode.php so
>>> if some hacker call your file directly they will only see the html
>>> output not the php source.
>>>
>>>>
>>>> Any thoughts on what I might do about this dilemma?
>>>>
>>>
>>> Very simple example...
>>> .htaccess file
>>>
>>> RewriteEngine On
>>>
>>> RewriteRule ^(.*)\.html$ $1.php
>>>
>>
>> Excellent. Thank you all. I do have the ability to edit the
>> .htaccess file. I will go read more so as not to be quite as
>> dangerous as I am now.
>>
>
> Well, that was interesting.
>
> Using the above RewriteRule I did a test. And the only way it works is
> if I rename the calling .html file to .shtml. Which, obviously, defeats
> the purpose.
>
> Is this something that can configured/over-ridden using the .htaccess
> file? Or is it at the server configuration level (which I do not have
> access to)?
>

Could be the way they have the server setup. Obviously PHP is more
server intensive that HTML so they may no wish for you to have a blanket
conversion. There is another way maybe. Since you have access to the
..htaccess file then you should be able to setup a custom ErrorDoc.
Point your 404 Errors to a PHP script.

#.htaccess
ErrorDocument 404 /scripts/404.php


It is what I do in my site in my signature, It does a bit more to help
me log bad links and hacking attempts but basically you can do this with
your 404.php script:

Get the request URI $requested=$_SERVER['REQUEST_URI'];

make a hash (associative array) of all your obsolete pages "HTML" with
values the new PHP page. Here im semi-pseudocode:

IF the hash has the $requested as a key
{

$newPage = $myChanges[$requested];

then redirect with the script

header("HTTP/1.1 301 Moved Permanently");//inform it is permanent change
header("Location: $newPage" );
}

ELSE
{
Display your custom 404 message because this is a bad URL not and
obsolete one.
}


You might be able yo get around the restriction this way and it can be
just as transparent to the users.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Re: PHP include and changing page names

am 12.11.2007 16:02:53 von Ed Mullen

Jonathan N. Little wrote:
> Ed Mullen wrote:
>> Ed Mullen wrote:
>>> Jonathan N. Little wrote:
>>>> Ed Mullen wrote:
>>>>> I'm considering using PHP to include the menus on my Web pages.
>>>>> I've tested it and it works fine (even though I know next to
>>>>> nothing about PHP). My understanding is that the page that will
>>>>> import content using a PHP include must have a .PHP extension.
>>>>> Which means that all my page names (which now end in .html) will
>>>>> change. Which means that the search engine results will point to
>>>>> non-existent pages.
>>>>
>>>> The include file doesn't but the calling file may for it to parse
>>>> PHP, server settings dependent.
>>>>
>>>>
>>>> >>>> ...
>>>>
>>>> But it is advisable to make the include file fileWithPhpCode.php so
>>>> if some hacker call your file directly they will only see the html
>>>> output not the php source.
>>>>
>>>>>
>>>>> Any thoughts on what I might do about this dilemma?
>>>>>
>>>>
>>>> Very simple example...
>>>> .htaccess file
>>>>
>>>> RewriteEngine On
>>>>
>>>> RewriteRule ^(.*)\.html$ $1.php
>>>>
>>>
>>> Excellent. Thank you all. I do have the ability to edit the
>>> .htaccess file. I will go read more so as not to be quite as
>>> dangerous as I am now.
>>>
>>
>> Well, that was interesting.
>>
>> Using the above RewriteRule I did a test. And the only way it works
>> is if I rename the calling .html file to .shtml. Which, obviously,
>> defeats the purpose.
>>
>> Is this something that can configured/over-ridden using the .htaccess
>> file? Or is it at the server configuration level (which I do not have
>> access to)?
>>
>
> Could be the way they have the server setup. Obviously PHP is more
> server intensive that HTML so they may no wish for you to have a blanket
> conversion. There is another way maybe. Since you have access to the
> .htaccess file then you should be able to setup a custom ErrorDoc.
> Point your 404 Errors to a PHP script.
>
> #.htaccess
> ErrorDocument 404 /scripts/404.php
>
>
> It is what I do in my site in my signature, It does a bit more to help
> me log bad links and hacking attempts but basically you can do this with
> your 404.php script:
>
> Get the request URI $requested=$_SERVER['REQUEST_URI'];
>
> make a hash (associative array) of all your obsolete pages "HTML" with
> values the new PHP page. Here im semi-pseudocode:
>
> IF the hash has the $requested as a key
> {
>
> $newPage = $myChanges[$requested];
>
> then redirect with the script
>
> header("HTTP/1.1 301 Moved Permanently");//inform it is permanent change
> header("Location: $newPage" );
> }
>
> ELSE
> {
> Display your custom 404 message because this is a bad URL not and
> obsolete one.
> }
>
>
> You might be able yo get around the restriction this way and it can be
> just as transparent to the users.
>

Jonathan, thanks. This is obviously going to take more education and
research on my part to sort out. Since I have an eye exam in an hour,
and my pupils will be dilated for several hours, I probably won't be
doing much computing the rest of the day!

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
There's only two things that money can't buy and that's true love and
home grown tomatoes. - Guy Clark

Re: PHP include and changing page names

am 12.11.2007 16:09:00 von Ed Mullen

dorayme wrote:
> In article ,
> Ed Mullen wrote:
>
>> Is this something that can configured/over-ridden using the .htaccess
>> file? Or is it at the server configuration level (which I do not have
>> access to)?
>
> Server admins can block all your attempts. I had a case of this
> recently and the Uni concerned offered the back-up plan I
> mentioned in my previous post (to direct all .html to mirror .php
> ones)...
>

It's not so much that they're blocking anything, it's that, in order for
the RewriteRule to work, they are requiring the files have an .shtml
extension. And what I'm trying to accomplish is:

1. Not destroy bookmarks people have set to my pages (all currently
with .html extensions)
2. Not destroy references the search engines have already indexed to my
pages (ditto).

I need to more thoroughly investigate and understand Jonathan's
suggestions when I have the time.

Thanks!

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
In love the paradox occurs that two beings become one and yet remain
two. - Erich Fromm

Re: PHP include and changing page names

am 12.11.2007 16:27:51 von lws4art

Ed Mullen wrote:

> Jonathan, thanks. This is obviously going to take more education and
> research on my part to sort out. Since I have an eye exam in an hour,
> and my pupils will be dilated for several hours, I probably won't be
> doing much computing the rest of the day!
>

Yeah but everything is gonna look so coooooool! Have fun.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Re: PHP include and changing page names

am 12.11.2007 17:17:39 von mbstevens

Ed Mullen wrote:
> I'm considering using PHP to include the menus on my Web pages. I've
> tested it and it works fine (even though I know next to nothing about
> PHP). My understanding is that the page that will import content using
> a PHP include must have a .PHP extension. Which means that all my page
> names (which now end in .html) will change. Which means that the search
> engine results will point to non-existent pages.
>
> Any thoughts on what I might do about this dilemma?
>
In addition to the others' thoughts about server configuration,
I would suggest you also consider preprocessing. This won't work
on all sites, especially those that require re-writes from data bases
on the fly. But if you have mostly static pages with common menus,
preprocessing works very well. Your page names remain the same. You just
run the preprocessor on a local machine and upload the pages with FTP.

Re: PHP include and changing page names

am 12.11.2007 17:36:47 von BootNic

Ed Mullen wrote:
news:e7-dnTeEvLNua6ranZ2dnUVZ_v6rnZ2d@comcast.com:

> Ed Mullen wrote:
>> Jonathan N. Little wrote:
[snip]
>>> Very simple example...
>>> .htaccess file
>>>
>>> RewriteEngine On
>>>
>>> RewriteRule ^(.*)\.html$ $1.php
>>>
>>
>> Excellent. Thank you all. I do have the ability to edit the
>> .htaccess file. I will go read more so as not to be quite as
>> dangerous as I am now.
>>
>
> Well, that was interesting.
>
> Using the above RewriteRule I did a test. And the only way it works
> is if I rename the calling .html file to .shtml. Which, obviously,
> defeats the purpose.
>
> Is this something that can configured/over-ridden using the .htaccess
> file? Or is it at the server configuration level (which I do not have
> access to)?

You could try to use RedirectMatch in your .htaccess:

RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2

--
BootNic Monday November 12, 2007 11:36 AM
My problem lies in reconciling my gross habits with my net income.
*Errol Flynn*

Re: PHP include and changing page names

am 12.11.2007 17:42:41 von lws4art

BootNic wrote:

> You could try to use RedirectMatch in your .htaccess:
>
> RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2
What is this part? ^^^^


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Re: PHP include and changing page names

am 12.11.2007 17:51:37 von BootNic

"Jonathan N. Little" wrote: news:a9063$4738827b
$40cba7a5$12517@NAXS.COM:

> BootNic wrote:
>
>> You could try to use RedirectMatch in your .htaccess:
>>
>> RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2
> What is this part? ^^^^

(?i) is case-insensitive matching

--
BootNic Monday November 12, 2007 11:51 AM
Facts do not cease to exist because they are ignored.
*Aldous Huxley*

Re: PHP include and changing page names

am 12.11.2007 18:11:37 von lws4art

BootNic wrote:
> "Jonathan N. Little" wrote: news:a9063$4738827b
> $40cba7a5$12517@NAXS.COM:
>
>> BootNic wrote:
>>
>>> You could try to use RedirectMatch in your .htaccess:
>>>
>>> RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2
>> What is this part? ^^^^
>
> (?i) is case-insensitive matching
>


Ah! Unfamiliar with that one. But what good would case-insensitive
matching do when you are passing the basename through? Somefile.php
SomeFile.php, and SOMEFILE.php won't works if the file name is somefile.php

I would think case-insensitive matching would be useful is you are not
parsing the name

RedirectMatch 301 (?i)^THISFILE.HTML$ thatfile.php

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Re: PHP include and changing page names

am 12.11.2007 20:09:08 von Ed Mullen

mbstevens wrote:
> Ed Mullen wrote:
>> I'm considering using PHP to include the menus on my Web pages. I've
>> tested it and it works fine (even though I know next to nothing about
>> PHP). My understanding is that the page that will import content
>> using a PHP include must have a .PHP extension. Which means that all
>> my page names (which now end in .html) will change. Which means that
>> the search engine results will point to non-existent pages.
>>
>> Any thoughts on what I might do about this dilemma?
>>
> In addition to the others' thoughts about server configuration,
> I would suggest you also consider preprocessing. This won't work
> on all sites, especially those that require re-writes from data bases
> on the fly. But if you have mostly static pages with common menus,
> preprocessing works very well. Your page names remain the same. You just
> run the preprocessor on a local machine and upload the pages with FTP.
>

But, wouldn't that mean that the HTML that I want to include using PHP
would then be physically present in all the html files? Or am I
misunderstanding?

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
All that glitters has a high refractive index.

Re: PHP include and changing page names

am 12.11.2007 20:30:20 von Bergamot

Ed Mullen wrote:
> mbstevens wrote:
>>
>> I would suggest you also consider preprocessing.
>
> But, wouldn't that mean that the HTML that I want to include using PHP
> would then be physically present in all the html files?

The purpose of a preprocessor is to combine all the page parts into a
whole static page prior to uploading it to the server, instead of having
the server combine them. Whether this is a good idea for your site
depends on how large the site is and how often common code changes.

--
Berg

Re: PHP include and changing page names

am 12.11.2007 20:49:29 von Ed Mullen

Bergamot wrote:
> Ed Mullen wrote:
>> mbstevens wrote:
>>> I would suggest you also consider preprocessing.
>> But, wouldn't that mean that the HTML that I want to include using PHP
>> would then be physically present in all the html files?
>
> The purpose of a preprocessor is to combine all the page parts into a
> whole static page prior to uploading it to the server, instead of having
> the server combine them. Whether this is a good idea for your site
> depends on how large the site is and how often common code changes.
>

As I thought. Thanks.

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
If you can't be kind, at least have the decency to be vague.

Re: PHP include and changing page names

am 12.11.2007 21:03:35 von mbstevens

Ed Mullen wrote:

>
> But, wouldn't that mean that the HTML that I want to include using PHP
> would then be physically present in all the html files? Or am I
> misunderstanding?
>
Yes. Space is usually not a problem, since the extra code is only a K or less
per file. The time it takes to serve the page is also not a problem,
since no program except the server itself is called to serve the page.

An example of the kind of site a preprocessor would -not- work for would be
newegg.com. On a site like that, you're pulling little bits and pieces of
information from all sorts of places to generate a page.
But if your pages are mostly static, a preprocessor is a good way to
do things.

http://www.htmlhelp.com/links/preprocessors.html

....has a nice selection. Or just write your own for your special needs.
It doesn't take a lot of effort.

Re: PHP include and changing page names

am 12.11.2007 21:38:09 von BootNic

"Jonathan N. Little" wrote:
news:ac5e$47388945$40cba7a5$14401@NAXS.COM:

> BootNic wrote:
>> "Jonathan N. Little" wrote:
>> news:a9063$4738827b $40cba7a5$12517@NAXS.COM:
>>
>>> BootNic wrote:
>>>
>>>> You could try to use RedirectMatch in your .htaccess:
>>>>
>>>> RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2
>>>> What is this part? ^^^^
>>
>> (?i) is case-insensitive matching
>>
> Ah! Unfamiliar with that one. But what good would case-insensitive
> matching do when you are passing the basename through? Somefile.php
> SomeFile.php, and SOMEFILE.php won't works if the file name is
> somefile.php

The only thing it was redirecting was based on .html. So it would redirect
(SomeFile.html|SomeFile.HTML|SomeFile.hTmL) to SomeFile.php, and
(somefile.html|somefile.HTML|somefile.hTmL) to somefile.php

So a URL:http://example.com/index.HTML?a=apple
would redirect to http://example.com/index.php?a=apple

(http://example.com/index) = $1
(?a=apple) = $2

Without the case-insensitive matching the above URL would not be redirected
and so you would get http://example.com/index.HTML?a=apple

I suppose a good question would be is the redirect going to redirect to
(php|PHP).

> I would think case-insensitive matching would be useful is you are not
> parsing the name
>
> RedirectMatch 301 (?i)^THISFILE.HTML$ thatfile.php

The RedirectMatch is not intended to do error correction for case in the
filename or path, at least in my example, that's another subject.

--
BootNic Monday November 12, 2007 3:38 PM
"This is all very interesting, and I daresay you already see me
frothing at the mouth in a fit; but no, I am not; I am just winking
happy thoughts into a little tiddle cup."
*Nabokov, Lolita*

Re: PHP include and changing page names

am 12.11.2007 23:06:50 von dorayme

In article ,
Ed Mullen wrote:

> dorayme wrote:
> > In article ,
> > Ed Mullen wrote:
> >
> >> Is this something that can configured/over-ridden using the .htaccess
> >> file? Or is it at the server configuration level (which I do not have
> >> access to)?
> >
> > Server admins can block all your attempts. I had a case of this
> > recently and the Uni concerned offered the back-up plan I
> > mentioned in my previous post (to direct all .html to mirror .php
> > ones)...
> >
>
> It's not so much that they're blocking anything, it's that, in order for
> the RewriteRule to work, they are requiring the files have an .shtml
> extension. And what I'm trying to accomplish is:
>

Well, I just meant that no matter what you do, some server admins
will simply not allow any attempts to have .html files read for
the php in them in the way that .php named files are read. It
puts strain on the servers and there are some security concerns I
am told.

On one big commercial ISP, on a Windows server, I asked them to
allow all the .html files on one particular website to be read
for the php on it and suitably processed. Amazingly, they agreed
and did it. I did not want to upset previous arrangements but
wanted all the php on nearly every file to be active.

A big uni server, I tried the same and it was not allowed. They
blocked all attempts. But they offered the deal I outlined
before. Perhaps you might find it attractive, you make your
website with .php endings (simply grab all your local .html files
and change the endings and load to server). Leave all the old
..html files up on the server, it does not matter what is in them,
I think you can even scrub them of most content and make them
dummies. You then ask the server admin to direct any requests for
any .html files to your good .php files.

Anyway, I am no expert on this stuff. Good luck.

--
dorayme

Re: PHP include and changing page names

am 13.11.2007 21:11:36 von Ed Mullen

BootNic wrote:
> Ed Mullen wrote:
> news:e7-dnTeEvLNua6ranZ2dnUVZ_v6rnZ2d@comcast.com:
>
>> Ed Mullen wrote:
>>> Jonathan N. Little wrote:
> [snip]
>>>> Very simple example...
>>>> .htaccess file
>>>>
>>>> RewriteEngine On
>>>>
>>>> RewriteRule ^(.*)\.html$ $1.php
>>>>
>>> Excellent. Thank you all. I do have the ability to edit the
>>> .htaccess file. I will go read more so as not to be quite as
>>> dangerous as I am now.
>>>
>> Well, that was interesting.
>>
>> Using the above RewriteRule I did a test. And the only way it works
>> is if I rename the calling .html file to .shtml. Which, obviously,
>> defeats the purpose.
>>
>> Is this something that can configured/over-ridden using the .htaccess
>> file? Or is it at the server configuration level (which I do not have
>> access to)?
>
> You could try to use RedirectMatch in your .htaccess:
>
> RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2
>

Ok, that seems to be doing the trick! Thanks!

Now, how do I turn that off for a given folder on the Web server? Is
that possible? What would I put in the folder's .htaccess files?

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
A bartender is just a pharmacist with a limited inventory.

Re: PHP include and changing page names

am 13.11.2007 21:59:37 von Ed Mullen

BootNic wrote:
> Ed Mullen wrote:
> news:e7-dnTeEvLNua6ranZ2dnUVZ_v6rnZ2d@comcast.com:
>
>> Ed Mullen wrote:
>>> Jonathan N. Little wrote:
> [snip]
>>>> Very simple example...
>>>> .htaccess file
>>>>
>>>> RewriteEngine On
>>>>
>>>> RewriteRule ^(.*)\.html$ $1.php
>>>>
>>> Excellent. Thank you all. I do have the ability to edit the
>>> .htaccess file. I will go read more so as not to be quite as
>>> dangerous as I am now.
>>>
>> Well, that was interesting.
>>
>> Using the above RewriteRule I did a test. And the only way it works
>> is if I rename the calling .html file to .shtml. Which, obviously,
>> defeats the purpose.
>>
>> Is this something that can configured/over-ridden using the .htaccess
>> file? Or is it at the server configuration level (which I do not have
>> access to)?
>
> You could try to use RedirectMatch in your .htaccess:
>
> RedirectMatch 301 (?i)^(.*)\.html(.*)$ $1.php$2
>

Hmm. Everything seems to be working. I changed all the pages to .php.
and every link I've tried seems to be working just fine.

Except, now my custom error pages don't work. I left the .html error
pages on the server but I got the server's default 404 page instead of
mine. Then I thought, "Oh, right, dummy, change them to .php files!"
So I did. But I'm still getting the server's 401, 403 and 404 error pages.

My .htaccess file:

RedirectMatch 301 (.*)\.html$ http://edmullen.net$1.php
ErrorDocument 404 /404_error_not_found.php
ErrorDocument 403 /403_error_forbidden.php
ErrorDocument 401 /401_error_unauthorized.php

If I go to http://edmullen.net/bob.html, the server sends me to
http://edmullen.net/bob.php. Since that file doesn't exist, I get a 404
error but it isn't MY custom error page.

If I go to http://edmullen.net/bob.jpg I DO get sent to my custom 404
page since, obviously, there's no redirection of .jpg files.

Any ideas?

My brain hurts. I'm gonna go get a drink.

--
Ed Mullen
http://edmullen.net
http://mozilla.edmullen.net
http://abington.edmullen.net
I wonder how much deeper would the ocean be without sponges.