0
votes

I am trying to tidy up my site URL by removing the index.php entry script. There's a documented method to do this, found here: http://www.yiiframework.com/doc/guide/1.1/en/topics.url

The instructions basically to say to set 'showScriptName' to false within the Yii project config file.

They also say to enable the rewrite module within your Apache configuration. I manually enabled it within the httpd file for WAMP. See here. I could have also done it via the system tray interface.

Once that was saved, I restarted by server.

Lastly, (and this is what I'm the least sure about, but I copied it from instructions) I added some lines to the .htaccess file within the protected folder of my Yii Project.

    AllowOverride all
    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

Despite doing this, I am getting Not Found errors for every single one of my pages. I am unsure as to what has gone on for this to happen, or what I haven't done to enable it properly.

Thanks.

2

2 Answers

1
votes

That .htaccess content goes in the .htaccess file in the root directory not the protected folder. It should then work. From http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x read this:

We can create the file /wwwroot/blog/.htaccess with the following content.

1
votes

The following settings are what I use for every Yii project. Give that a shot.

.htaccess:

<ifModule mod_rewrite.c>
# Turn on the engine:
RewriteEngine on
# Don't perform redirects for files and directories that exist:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For everything else, redirect to index.php:
RewriteRule ^(.*)$ index.php/$1
</ifModule>

/protected/config/main.php

'urlManager'=>array(
    'showScriptName'=>false,