user2632980
user2632980

Reputation: 551

How to remove index.php from URL

My yii application was installed in virtual host(http://yii.loc) (WAMP). I need to remove index.php from url. But only http://yii.loc url works, the other pages says "Not Found".

'urlManager'=>array(
    'urlFormat' => 'path',
    'showScriptName' => false,
    'rules' => array(
        '<controller:\w+>/<id:\d+>' => '/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '/',
        '<controller:\w+>/ <action:\w+>' => '/',
),

.htaccess

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

Upvotes: 0

Views: 254

Answers (2)

user2632980
user2632980

Reputation: 551

Got a solution. By mistake I have changed the .htaccess which are located in protected folder. So I restored the file

deny from all

The I created a new .htaccess file in the root directroy and add

Options +FollowSymLinks
IndexIgnore */*
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

And now it works.

Upvotes: 0

Altenrion
Altenrion

Reputation: 774

Check out the settings of Apache. I had same problems when the rewrite rule was disabled.

Go to WAMP icon->Apache modules->rewrite_module and turn it on

Than try to restart your WAMP & aplication in browser)

Upvotes: 3

Related Questions