9

Is there any way, from a PHP script called from mod_php with apache, to tell apache to do an INTERNAL redirect to some other file?

I do not want to read/require this file from PHP and spit it out, I think it'd be more efficient to pass this off to Apache. I believe this can be done with mod_perl and I'm curious if there's a way to do it with PHP/mod_php/apache.

Thanks!

bnjmnhggns
  • 103
  • 1
  • 4

1 Answers1

3

virtual() may do what you want. I'm not sure, I've never tried it.

Note that include() and require() will work if you're just calling HTML or PHP pages, plus be portable to other PHP installations.

I vaguely remember that using a Location header with a local url as doing an internal redirect (such as header("Location: /uri/here.php");, but I can't test it here to make sure.

Powerlord
  • 87,612
  • 17
  • 125
  • 175
  • Um, it even says in the docs you linked to that using virtual() on PHP files is possible, but include() or require() are better. OP is doing it wrong. – Nathan Strong Nov 06 '08 at 21:20
  • Yes, it does, but I was answering the question that the OP asked (how to do an internal redirect). virtual() does an actual Apache subrequest for the new page, meaning that things from other languages (or compiled programs) still work. – Powerlord Nov 07 '08 at 12:59
  • Also, the OP said "I do not want to read/require this file from PHP..." – Powerlord Nov 10 '08 at 20:51