Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create friendly links in Yii project using Yiinitializr
    text
    copied!<p>I try to use Yiinitializr site structure for my Yii project. The structure looks like this:</p> <pre><code>root --backend ----standart yii folders ----... ----www ------index.php (admin.mysite.com) --common ----common folders for backend and frontend ----... --backend ----standart yii folders ----... ----www ------index.php (mysite.com) </code></pre> <p><a href="https://github.com/tonydspaniard/yiinitializr-intermediate" rel="nofollow">Blank Yiinitializr strucure see on github</a></p> <p>The question is how to make working URLs like this:</p> <pre><code>admin.mysite.com/invites - in backend </code></pre> <p>and </p> <pre><code>mysite.com/users - in frontend </code></pre> <p>Troubles with routing appeared when i uploaded project on virtual hosting. Backend for example:</p> <pre><code>admin.mysite.com/backend/www/?r=site/invites - working properly admin.mysite.com/backend/www/invites - working properly admin.mysite.com/?r=site/invites - working properly admin.mysite.com/invites - redirects to index </code></pre> <p>Root folder has own .htaccess with this content:</p> <pre><code>RewriteEngine On RewriteRule ^backend/www/ - [last] RewriteCond %{HTTP_HOST} admin.mysite.com [nocase] RewriteRule (.*) backend/www/$1 [last] RewriteRule ^frontend/www/ - [last] RewriteCond %{HTTP_HOST} !admin.mysite.com [nocase] RewriteRule (.*) frontend/www/$1 [last] </code></pre> <p>backend/www/.htaccess have rewrite rules:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php &lt;/IfModule&gt; </code></pre> <p>And Yii urlManagers code:</p> <pre><code>'urlManager' =&gt; array( // uncomment the following if you have enabled Apache's Rewrite module. 'urlFormat' =&gt; 'path', 'showScriptName' =&gt; false, 'rules' =&gt; array( // default rules '&lt;page:\w+&gt;' =&gt; 'site/&lt;page&gt;', '' =&gt; 'site/index', '&lt;controller:\w+&gt;/&lt;id:\d+&gt;' =&gt; '&lt;controller&gt;/view', '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;', '&lt;controller:\w+&gt;/&lt;action:\w+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;', ), ), </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload