Jump to content

Access file in another directory


ciber

Recommended Posts

Firstly let me explain my directories:

 

/home/user/public_html/ which makes use of mysite.com

/home/user/images/ which makes use of img.mysite.com

 

basically I am splitting my images up, to monitor traffic on them - however, I need them to remain in the directory they are in.

Therefore, if a file is accessed img.mysite.com, how can I get the server to rewrite to /home/user/public_html/images/ ?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/207227-access-file-in-another-directory/
Share on other sites

The 'correct' way of doing this would not be via mod_rewrite. You should be setting up img.mysite.com with it's own named virtualhost via an apache .conf file. Assuming this isn't an option for you it can be done with mod_rewrite, you'd use something like this....

 

RewriteCond %{HTTP_HOST} ^img.mysite.com
RewriteRule ^.*$ http://mysite.com/images/%{REQUEST_URI}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.