Welcome Guest, Not a member yet? Register   Sign In
htaccess: Get files from another directory
#1

[eluser]codex[/eluser]
What I'm trying to achieve is that files called via

Code:
http://www.domain.com/files/
are being served from the real directory

Code:
http://www.domain.com/assets/files/whatever/blah/

In my htaccess I have this

Code:
RewriteRule ^http://www.domain.com/files/$ http://www.domain.com/assets/files/whatever/blah/

but that doesn't work. Am I doing something wrong here or is it just not possible?
#2

[eluser]TheFuzzy0ne[/eluser]
I am no expert on the subject, but:
Code:
^http://www.domain.com/files/$

will only match if there is nothing appended after the end of the string. I'd also suggest doing an internal redirect rather than telling the browser to look in assets/files/whatever/blah/.

This might work:
Code:
RewriteRule ^(files/.*) assets/$1 [L]
#3

[eluser]codex[/eluser]
[quote author="TheFuzzy0ne" date="1237573879"]I am no expert on the subject, but:
Code:
^http://www.domain.com/files/$

will only match if there is nothing appended after the end of the string. I'd also suggest doing an internal redirect rather than telling the browser to look in assets/files/whatever/blah/.

This might work:
Code:
RewriteRule ^(files/.*) assets/$1 [L]
[/quote]

Thanks, but unfortunately that doesn't work either. The internal redirect however works! My only concern is performance. Let's say you have a lot of images on the same page all doing the redirect, wouldn't that hurt performance?
#4

[eluser]TheFuzzy0ne[/eluser]
I'd have to say that the performance hit is negligible if you're redirecting internally. If it really matters to you, then perhaps you'd be better of using a symlink if you're able to.
#5

[eluser]codex[/eluser]
[quote author="TheFuzzy0ne" date="1237576533"]I'd have to say that the performance hit is negligible if you're redirecting internally. If it really matters to you, then perhaps you'd be better of using a symlink if you're able to.[/quote]

I think this will do fine. I don't see any difference in performance (yet).

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB