.htaccess for the site in a subdirectory using the Yii schema

I looked at some examples of htaccess configurations for sites in subdirectories and tried most of them 100% unsuccessfully.

My setup :

  • using the Yii infrastructure
  • htaccess at public_html/.htaccess
  • located inside the catalog public_html/mysite
  • index processing all queries located in public_html/mysite/frontend/www/index.php

URL Status :

  • www.mysite.com working fine [ok]
  • www.mysite.com/controller/actionshows me the homepage [wrong]
  • www.mysite.com/mysite/frontend/www/controller/actionworks fine [wrong, the item above should work instead]

My .htaccess currently looks like this:

AddHandler application/x-httpd-php53s .php .html

Options +SymLinksIfOwnerMatch
IndexIgnore */*

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

RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/mysite/frontend/www

RewriteRule ^(.*)?$ /mysite/frontend/www/index.php [L]

I tried everything, but I have no idea why www.mysite.com/controller/action will not work :(

! !

+5
4

, . :

#Forward all non-existent files/directories to Yii
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) subdir/index.php/$1 [QSA,L]

/ yii script URL-. QSA , URL-.

+4

, Yii Url Manager URL-. , Yii , "" GET "r". ,

0

.htaccess. Yii script (index.php) .htaccess webroot ( public_html). index.php .htaccess , - index.php( ), / URL-.

index.php, yii.php( Yii framework), Yii (main.php). , -, Yii , , script).

That should be all you need to do, but if you need more details, I fully describe this approach here:

http://muhammadatt.tumblr.com/post/83149364519/modifying-a-yii-application-to-run-from-a-subdirectory

0
source

I also did not update the file .htaccess, it is easier to change the virtual host httpd.conffor the subdomain and change DocumentRootto point to your yii folder.

0
source

All Articles