Re: Using Apache's mod_rewrite to hide scripts extension
- From: Tim Roberts <timr@xxxxxxxxx>
- Date: Wed, 30 Apr 2008 06:25:55 GMT
Jerry Stuckle <jstucklex@xxxxxxxxxxxxx> wrote:
Oops - I think I misread what you are doing (twice!).
If I understand this correctly now, you have your PHP code in .php
files, and have Apache set up to load those PHP files if the equivalent
.html is called. This would be OK.
...
But you don't want the .php files to be able to be loaded directly. I'm
not sure what difference it makes - does it cause a problem to load the
.php file?
From the PHP end, yes, you can restrict access. But if you want to do
it with mod_rewrite, you really need to be following up on an Apache
newsgroup. You'll get expert answers there.
mod_rewrite is one of those magical products that can be configured to do
practically anything (like Sendmail). And like most such products, it is
difficult to get right.
However, I think this will do what the original poster wanted:
RewriteEngine On
RewriteRule ^(.*)\.php$ $1.php [R=404,L]
RewriteRule ^(.*)\.html$ $1.php [L]
That says PHP references should redirect to a 404, and HTML references
should be rewritten to PHP.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.
- Follow-Ups:
- Re: Using Apache's mod_rewrite to hide scripts extension
- From: "Álvaro G. Vicario"
- Re: Using Apache's mod_rewrite to hide scripts extension
- References:
- Using Apache's mod_rewrite to hide scripts extension
- From: "Álvaro G. Vicario"
- Re: Using Apache's mod_rewrite to hide scripts extension
- From: Jerry Stuckle
- Re: Using Apache's mod_rewrite to hide scripts extension
- From: "Álvaro G. Vicario"
- Re: Using Apache's mod_rewrite to hide scripts extension
- From: Jerry Stuckle
- Using Apache's mod_rewrite to hide scripts extension
- Prev by Date: Re: herf link to php page
- Next by Date: Re: Using Apache's mod_rewrite to hide scripts extension
- Previous by thread: Re: Using Apache's mod_rewrite to hide scripts extension
- Next by thread: Re: Using Apache's mod_rewrite to hide scripts extension
- Index(es):
Relevant Pages
|