开发者

.htaccesss two sites

I have two sites running in the same domain (the same sites, but the old in wor开发者_开发知识库dpress and the new custom)

I need to do:

If the client ask for a file that exists, then he can see it: (this works)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Any other request goes to index.php

 RewriteRule . /index.php [L]

Ok... but if you ask for / (www.site.com) you will have be redirected to www.site.com/site2 without going trough index.php

how can I achieve this? in pseudocode (bad english, sorry)

if(request == "/" || request == www.site.com) {
    redirect site2/
} else if(ask_for_a_file_that_exists) {
    server file
} else {
    use old index.php
}


Something like this should work:

# Check if the request was for the root, and if so, redirect
# internally to the site2 folder
RewriteRule ^$ /site2/ [L]

# Otherwise, let the existing site take care of the rest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜