Forum Moderators: phranque

Message Too Old, No Replies

Rewrite rule for a different directory path, even for PHP includes

         

premasagar

7:24 pm on Oct 5, 2004 (gmt 0)

10+ Year Member



Hi there,
I am trying to use htaccess to rewrite requests for the root directory of the site to a specific folder on the site.

E.g.
/images/image.jpg will be rewritten as
/new/images/image.jpg

Now, the thing is, I want this to apply to all PHP include() and require() statements. Is this possible with htaccess? I suspect it may not be.

I am currently trying to use:
RewriteRule \/(.*) /new/$1 [L]

But I think this will only work for whole page requests, not for include files.

Any suggestions?
Thanks, Prem.

jdMorgan

8:15 pm on Oct 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Prem,

The includes are handled in the filespace of the server, and not in Web URL space, so mod_rewrite won't help there. You might want to look into symlinks for your solution.

If you code is intended for use in .htaccess, I'd recommend:


RewriteCond %{REQUEST_URI} !^/new
RewriteRule ^(.*) /new/$1 [L]

But this still won't affect local file includes.

Jim

{edited] Fix typo [/edited]

[edited by: jdMorgan at 5:12 pm (utc) on Oct. 8, 2004]

premasagar

2:51 pm on Oct 8, 2004 (gmt 0)

10+ Year Member



Thanks for the reply. I have started looking into some alternative approaches.

Prem.