W
W
wartur2012-07-19 21:05:22
Yii
wartur, 2012-07-19 21:05:22

How to correctly compose a .htaccess rule?

Honestly, it's either evening or whatever, but I just can't figure out the simplest rule.
In general, I have Yii which lies in a directory, let's say:
/v2
(/v2/index.php) - the launch file and let's go
to the root, I have other scripts, and other files that can be loaded.
How to make Apache redirect to Yii any request that doesn't match any root files or scripts?
For files, I assume these commands are needed:

RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>

RewriteRule (how is this???)
In general, the task is for the server to somehow move to the /v2/ directory and there it already has another htaccess that will work.
I would be really grateful for your help. I’ll add on my own, I’ve been in different ways, but in one case, routing in Yii flew off, in another, something unimaginable happened.
UPD:
If anyone is interested, I found a workaround:
I requested the launch of Yii through a php file, here is its code:
require '/v2/index-chdir.php';<br>
// index-chdir.php - спец запускающий файл, с доп кодом chdir(__DIR__);<br>

And here is the .htaccess code:
# если нет файла или директории<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br><br>
# передать все запросы к прокси файлу<br>
RewriteRule . yiiproxy.php<br>

UPD2: Sorry
for the trouble. I stepped on something, of course, when rewriting, the routing will beat and the right decision, this is exactly what I wrote. Right, if there are more offers, I will not refuse. Thank you for your attention, I leave the question to the conscience of the search engines. PS: why are you downvoting?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Inori, 2012-07-19
@wartur

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /v2 [QSA,L]

M
marklarius, 2012-07-19
@marklarius

It is also desirable to add [L] k RewriteRule

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question