4

I am working with Yii Framework on Apache/2.2.15 (CentOS) Server.


Following line is uncommented in /etc/httpd/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so


I can see mod_rewrite under Loaded Module when I do following

<?php phpinfo(); ?>


Yii Project Structure:

/var/www/test/ 
/var/www/test/index.php 
/var/www/test/.htaccess


.htaccess content

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


It works fine when I do:

http://10.20.30.40/test/index.php/testcontroller/testaction


But when I do:

http://10.20.30.40/test/testcontroller/testaction

It shows following error:

Not Found

The requested URL /var/www/test/index.php was not found on this server.

Any idea?

1
  • @Awan have you solved this problem? I have having same issue, please help me if you have solved it. Thanks +1 :) Commented Jul 18, 2013 at 14:01

4 Answers 4

4

I have the same trouble. I use Apache config alias, like:

<VirtualHost *:80>
...

Alias /project "/Users/foo/Sites/project"

...
</VirtualHost>

To solve, I use "RewriteBase" directive on .htaccess, example:

RewriteEngine on
RewriteBase /project # <---- Modify here! and remove this comment.

# 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

Source: http://www.yiiframework.com/wiki/214/url-hide-index-php/#c9725

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

Comments

2
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

htaccess content.

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

urlmanager config in your main.php. Or you can customize it if you want.

1 Comment

Read yiiframework.com/doc/guide/1.1/en/topics.url topic. It will be usefull.
2

Ensure that AllowOverride is "All" for your project's web directory in httpd.conf. If not, change the value and restart the web server

Comments

0

I solved this editing the Apache Configuration file at: {{ApacheDir}}/conf/httpd.conf
And Un-commenting / Adding the following line: LoadModule rewrite_module modules/mod_rewrite.so

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.