Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving index.php from URL cause 404 in yii
    primarykey
    data
    text
    <h1>The problem</h1> <p><strong>Initial problem:</strong> Hi I have a newly made Yii site where I want to remove the index.php from the URL.<br> Example: "/index.php/site/index" should be "/site/index"</p> <p>I have been using this <a href="http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x" rel="nofollow">http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x</a> guide but i only receive 404. </p> <p>I hope that you are able to point a mistake or help me debug this problem!<br> Please let me know if I have left out any relevant information.</p> <p>OBS: The "home" page works as intended, other pages are broken.</p> <p><strong>Status of the problem:</strong> It seems like it is an apache/ubuntu problem with mod_rewrite.so</p> <h2>Answer</h2> <p>After help from different people it all works now :D I had to install "rewrit" to get it running, i did that by writing Running a2enmod rewrit The below configuration of my system solved the problem for me, I hope this thread will help others in similar problems.</p> <h2>My system</h2> <pre><code>Server version: Apache/2.2.22 (Ubuntu) Server built: Nov 8 2012 21:37:45 </code></pre> <h3>Apache httpd.conf</h3> <pre><code>&lt;Directory "/var/www/MY_SITE/FOLDER_CONTAINING_YII/"&gt; AllowOverride All #... &lt;/Directory&gt; LoadModule rewrite_module modules/mod_rewrite.so </code></pre> <p><em>This is the entire content of the file</em></p> <h3>Apache Error Log</h3> <pre><code>File does not exist: /.../htdocs/site, referer: http://.../htdocs/index.php/site/index </code></pre> <p><em>I added the dots</em></p> <h3>Restart Apache</h3> <pre><code>kah@webaalborg:/etc/apache2/sites-available$ sudo service apache2 restart * Restarting web server apache2 [Mon Nov 26 20:16:35 2012] [warn] module rewrite_module is already loaded, skipping ... waiting [Mon Nov 26 20:16:36 2012] [warn] module rewrite_module is already loaded, skipping [ OK ] </code></pre> <h3>/ect/apache2/available-sites/default</h3> <pre><code>... DocumentRoot /var/www &lt;Directory /&gt; Options FollowSymLinks AllowOverride None &lt;/Directory&gt; &lt;Directory /var/www/&gt; Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all &lt;/Directory&gt; &lt;Directory /var/www/MY_SITE&gt; Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all &lt;/Directory&gt; ... </code></pre> <h3>Yii Directory structure:</h3> <ul> <li>framework </li> <li>htdocs <ul> <li>assets</li> <li>css</li> <li>.htaccess</li> <li>index.php</li> <li>index-test.php</li> <li>themes</li> </ul></li> <li>protected</li> </ul> <h3>.htaccess</h3> <pre><code>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 . index.php </code></pre> <h3>main.php config file</h3> <pre><code>'urlManager'=&gt;array( 'urlFormat'=&gt;'path', 'showScriptName'=&gt;false, 'caseSensitive'=&gt;false, 'rules'=&gt;array( '&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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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