Yii Framework Forum: Chapter 2 - Urls - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 2 - Urls rewriting isn't working

#1 User is offline   haosmark 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-January 13

Posted 19 February 2013 - 02:51 PM

I followed the book closely, but it just isn't working. Looks like the only rule that is ever applied in Apache is
RewriteRule . index.php

My project directory is as follows (I'm using XAMPP): C:\xampp\htdocs\ppwk\

Here are the changes that I made inside:
protected/controllers/WebsiteController.php
class WebsiteController extends CController
{
    public function actionIndex()
    {
        echo 'index';
    }

    public function actionPage($alias)
    {
        echo "page is $alias";
    }
}

protected/config/main.php
        'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                'home'=>'website/index',
                '<alias:about>'=>'website/page',
                'page/<alias>'=>'website/page',
            ),
        ),

htdocs/ppwk/.htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

#if a dir or file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#otherwise forward it to index.php
RewriteRule . index.php

I guess the problem is in htaccess file, can someone tell me what the problem is?

Thanks.
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,336
  • Joined: 17-January 09
  • Location:Russia

Posted 19 February 2013 - 03:40 PM

htaccess looks OK. At least it's the same htaccess everyone are using for Yii + Apache so htaccess itself should not be a problem.

Try adding 'showScriptName' => false to urlManager config and then open http://your.localhos...s/website/index
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#3 User is offline   haosmark 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-January 13

Posted 19 February 2013 - 03:54 PM

I hate when this happens, I had a different project open in my IDE, lol.
it's working now.
0

#4 User is offline   Mohammad Tokallo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 25-June 12

Posted 19 February 2013 - 05:26 PM

View Postsamdark, on 19 February 2013 - 03:40 PM, said:

htaccess looks OK. At least it's the same htaccess everyone are using for Yii + Apache so htaccess itself should not be a problem.

Try adding 'showScriptName' => false to urlManager config and then open http://your.localhos...s/website/index


hi samdark

i dont know why when i set showScriptName=>false , and i open site like =>localhost/app/cntr/act it shows 404 but with localhost/app/index.php/cntr/act it works?
0

#5 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,336
  • Joined: 17-January 09
  • Location:Russia

Posted 20 February 2013 - 07:39 AM

Looks like your Apache is not reading htaccess.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users