PHP include and changing page names

B

BootNic

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*
 
D

dorayme

Ed Mullen said:
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.
 
E

Ed Mullen

BootNic said:
Ed said:
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.
 
E

Ed Mullen

BootNic said:
Ed said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top