httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Krist van Besien" <krist.vanbes...@gmail.com>
Subject Re: [users@httpd] URLRewrite Question
Date Fri, 02 Feb 2007 14:27:58 GMT
On 2/2/07, Feris Thia <feris.apache.httpd@gmail.com> wrote:
> Hi Everyone,
>
> I configured my .htaccess to map/redirect all my *.html page to *.php pages
> like below
>
> ================================
>  RewriteEngine on
> RewriteRule ^([0-9a-zA-Z]+)\.html$ $1.php
> ================================
>
> It works. But now, I want the client cannot access the php script directly.
> So I write the rule like these
>
> ================================
>  RewriteCond %{REQUEST_URI}  "\.(php)$"
> RewriteRule .* - [F]
> ================================
>
> But now it forbid every *.html  that maps to my *.php pages... What is wrong
> ? How can I achieve my goal ?

RewriteRule processing doesn't stop when a rule matches, unless you
tell it to. So you first rewrite *.html to *.php and then tell your
server to forbid access to *.php, and you get exactly that.

First a question: Why do you want to do this? This will cause all
kinds of trouble, like when a piece of php generates self referencing
urls, that will naturlally end in .php. Forms for example work like
this.

What you can do however is:
- Play with the order of the rules.
- Add the [L] flag to stop processing.
>
>
> Regards,
>
> Feris
>


-- 
krist.vanbesien@gmail.com
Bremgarten b. Bern, Switzerland
--
"...what you don't realize is that in the future Google WILL reach
sentience, will [have had] invent[ed] a time machine, and will [have
had] travel[ed] back in time to prevent Bill Gates... only to become
Bill Gates by accident because of a search engine optimization
miscalculation." (Comment on the Dilbert Blog)

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message