Re: Using Apache's mod_rewrite to hide scripts extension



Tim Roberts escribió:
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.

It doesn't work either because when I request foo.html I'm silently redirected to foo.php, rewriting starts again and first rule generates a Not Found status code.

Thank you for your suggestion but it's really tricky!

I've asked my newsmaster if I can get "alt.apache.configuration" added to the groups lists (Google Groups is okay but it does not allow e-mail obfuscation) but I guess I'll implement this as is and I just won't care about direct access to *.php files (or I'll check $_SERVER['REQUEST_URI'] and generate the 404 status in PHP). Your comparison of mod_write with Sendmail has scared me to the bone ;-)


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.



Relevant Pages

  • Re: Using Apaches mod_rewrite to hide scripts extension
    ... RewriteRule ^\.html$ $1.php ... That says PHP references should redirect to a 404, ...
    (comp.lang.php)
  • Re: Using Apaches mod_rewrite to hide scripts extension
    ... RewriteRule ^\.html$ $1.php ... That says PHP references should redirect to a 404, ...
    (comp.lang.php)
  • Re: Post with redirect?
    ... you made it about javascript, ... He wanted a way to redirect a port with data to an external site and I gave it to him. ... And you still haven't showed us how to do a redirect with post values in PHP. ... the only thing jerry got right is that it would be a lot of work. ...
    (comp.lang.php)
  • Re: Post with redirect?
    ... redirection...and how to do a post from php (which you said was ... Oh, so you aren't even as good as a script kiddie, huh? ... I said it was impossible to redirect from PHP. ... Now who's backpeddling, troll? ...
    (comp.lang.php)
  • Re: Post with redirect?
    ... He wanted a way to redirect a port with data to an external site ... posting certain inputs, with the 3rd party server as the target. ... i made no claim other than you can use just php to get the job done. ... only thing jerry got right is that it would be a lot of work. ...
    (comp.lang.php)