E
E
Evgeny Ilin2013-01-14 13:21:13
PHP
Evgeny Ilin, 2013-01-14 13:21:13

Is it possible to "spread" requests for the same file via mod_rewrite?

Hey habr!
Permanent laziness affects the New Year holidays, I can not solve the problem through mod_rewrite.
At the moment, there is a temporary solution, but not a killable share of perfectionism, but partly of shame protests and asks to find a LITERAL one.
There is a new site /site/ , there is an old site /site/old/ .
The templates of the old site are laid out in such a way that all statics are requested from the root. In fact, it’s impossible to edit anything (although if I press it, I’ll write a parser).
Thus, a rule is needed that all requests from
site/old/ to /site/style.css would redirect to /site/old/style.css
While I made a rule for the root .htaccess
RewriteRule ^(.*)\.(css|js|jpg|png|gif)$ old/$0
(the root directory is still empty and suffers such mockery).
However, the static is now served from a different directory.
As far as I understand, any rules from /site/old/.htaccess to /site/ will be ignored. Or not?
How can I catch a request to /site/style.css from /site/old/ and ignore the request for statics from root?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wott, 2013-01-14
@geirby

Use RewriteCond with HTTP_REFERER for static

R
romy4, 2013-01-16
@romy4

If you just need to forward to another directory, then use the [PT] flag for RewriteRule so that the subrequest is already processed where you threw it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question