0

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That's what I must have misread. I did both what you said, and what @visevo did, and now I am getting the desired effect. Thanks.
1

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,

1 Comment

Thanks for this. It seems like a much better piece of code to have than mine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.