.htaccess RewriteRule with PHP include

altariamx2003 used Ask the Experts™
I hope you can help me with this

in my htaccess I add this rule RewriteRule ^pruebas/(.*).php$ /oculto/controladores/php/$1.php [L,NC,QSA]

This rule allow me to redirect this kind of url "http://grupossc.com/pruebas/the_test.php", this rule work without problems.

but when I try  to use for example that link with a php include statement like <?php include ("pruebas/the_test.php"); ?> to import a php file with some functions it doesnt work

What Im doing wrong??? it is possible to use a redirected url inside of a php include statement?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The .htaccess file only affects the web requests. It does not affect anything else. It is simply a file that has some extra configuration for the web server.

When you have:
<?php include ("pruebas/the_test.php"); ?>

...the PHP code is looking directly at the file system. It is not going through the web server, so it is not affected by the .htaccess file.

If you want everything in pruebas to go to oculto/controladores/php, then you MIGHT be able to use a symbolic link to do that. However, you usually need shell access to do the link, and you often have to tell the web server to accept / follow symbolic links. It can get tricky if you are not familiar with the filesystem, and you could potentially lose your data if you don't know what you're doing, so just be careful if you try it.


thx bro, Ill check about symbolic links

thx to take time to answer me

best regards


Thx to gr8gonzo

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial