use site.com/ instead site.com/yii, how ?

Hello guys !

I have such a question:

project domain is site.com for example

there is yii folder under this domain so yii project is awailable under URL

so if I go to http://site.com/yii/site/page/view/about I see about page,

what I need to do is to remove yii from url, so I can use http://site.com/ instead of http://site.com/yii

is it possibile ?

I tried to change curlmanager baseUrl property but it did not help.

How does your folder structure look?

/yii/ is not normally part of the url and is probably there because you extracted it to a subfolder.

So, if your index.php is at yii/index.php you will need to move everything from yii/ to the root directory

yes I extracted it to subfolder specially,

see thing is that I need to separate 2 different projects (old and new(yii) one) inside 1 domain name, so if I go to site.com/index.php?action=someaction then it shows me old proejct info, old proj does not use SEO urls

and if I go to site.com/posts/ for example then yii app is executed and I see posts page.

Thats’ why I exctracted new project under yii folder so it will not interfere with old project because both of them uses index.php as start file.

I need to make them work together on same domain, sounds weird but I have to do it

Now I have an another idea how to make them work, is it possible that yii use some other script name as start script? for example if I create start.php and use it instead of index.php for yii project ? if it’s possible then I don’t need a subfolder for yii project and I can put it on same directory level as old project. Old proj will still use index.php as start script and yii proj will use start.php then

not sure if it will work, will try that tomorrow.

Yes this is possible, you would need to use .htaccess (if you are on apache, this doesn’t apply for iis) and mod_rewrite to control the paths of different requests.

Essentially mod_rewrite is part of apache (placed in .htaccess) that changes the route of a url. So for example with the standard yii .htaccess you have:


RewriteRule . index.php [L,QSA]

This says route all requests to index.php, so when you visit site.com/posts, apache "rewrites" it to site.com/index.php and yii can pull the "posts" part to handle the requests

.

You can play around with htaccess to get your desired result, but from what you are saying it seems like your .htaccess would look something like:


RewriteEngine On


# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php

RewriteRule . start.php



so you would have index.php and start.php, one mapping to your old controller and one to the new one. Since you are accessing the old one via /index.php you don’t need anything special because the line


RewriteCond %{REQUEST_FILENAME} !-f

says only rewrite if the request is not a file

Hope that helps

don’t need to be that complicated.

Just change the web root in your server.

I don’t remember it’s in your php.ini or somewhere. You can google it.

it depends.

jiaming, this will not help me as I need to keep index.php as default entry script for old project version in same time I need start.php as entry script for new project version which placed in same folder.

crasx , it works ! thanks that is exactly what I need !