0

my code runs with url:

http://localhost/yii/index.php/Adminlogin

I want url to look like:

http://localhost/yii/Adminlogin

.htaccess file

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

main.php

'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName'=>false,
        'rules'=>array(
            'redirect/<redirectUrl>'=>'site/index',
            'login'=>'site/login',
            'privacy'=>'site/privacy',
            'password'=>'site/forgot',
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),
    ),
2

5 Answers 5

1

RewriteRule ^ index.php [L] instead of RewriteRule . index.php

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

Comments

1

Use this in your main.php

'urlFormat'=>'path',
'showScriptName'=>false,

And in your htaccess use below,

RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]

Comments

0

Try this

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php(.*) [NC]
RewriteRule ^(.*)index\.php(.*)$ http://%{HTTP_HOST}$1/$2 [R=301,L]

or

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php(.*) [NC]
RewriteRule ^index\.php(.*)$ http://%{HTTP_HOST}$1 [R=301,L]

Comments

0

Also, ... remember to AllowOverride in your main apache configuration:

<Directory "/path/to/your/yii.sample/web/">
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any
    AllowOverride All
    Require all granted
    allow from all
</Directory>

Is it possible that your web/.htaccess is correct, but your apache never allowed your

Comments

0

my htaccess would look like

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

and in main.php

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

Comments

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.