Problems hiding index.php of the path

Hi people!

I have problems hiding the index.php of the path

… my configurations

main.php




'urlManager'=>array(

			'urlFormat'=>'path',           

            'showScriptName'=>false,

            'rules'=>array(

                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>'

            ),

		),



.htaccess




Options +FollowSymLinks

IndexIgnore */*

<IfModule mod_rewrite.c>

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

</IfModule>



In the httpd.conf file of apache (I’m using WAMP 5)

I uncomment




LoadModule rewrite_module modules/mod_rewrite.so



and I change None to All




<Directory />

    Options FollowSymLinks

    AllowOverride All

    Order deny,allow

    Deny from all

    Satisfy all

</Directory>



… I restart all services and nothing happened When I try to access to a page I get the error


Not Found


The requested URL /myProject/site/aboutUs was not found on this server.

myProject is the name of my project folder inside the www folder of WAMP

When I comment (showScriptName=>false), in the main.php, the page shows correctly but with this type of path

localhost/myProject/index.php/site/aboutUs

I can’t hide index.php

I read the all post about this problem but I can’t solve the problem …How Can I fix this issue??

Regards

Is the error generated from Apache or from Yii?

If it’s Apache the rewriting to index.php does not work. I remember having issues with subfolders sometimes. You could add this to your rewrite configuration, maybe it helps:


RewriteBase /myProject

You can also enable RewriteLog and set RewriteLogLevel (only possible in httpd.conf, though), to get loads of debugging from your rewrite module. This should help to find out, what’s going on. More details here:

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Hi! Thnx for the answer

How I know if the error is from Apache or Yii?? I supose actually is from Yii

I added RewriteBase /myProject




Options +FollowSymLinks

IndexIgnore */*

<IfModule mod_rewrite.c>

RewriteEngine on


RewriteBase /myProject


# 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

</IfModule>



but the error is the same

I add this lines to the httpd.conf to enable the rewritelog




...

RewriteLog "c:/wamp/www/rewrites.log"

RewriteLogLevel 5

RewriteEngine on

...



and when I try to access the page ‘aboutUs’, I get this log




127.0.0.1 - - [27/Jan/2011:07:38:06 --0500] [localhost/sid#2bfe38][rid#107cbc0/initial] (2) init rewrite engine with requested uri /myProject/site/aboutUs

127.0.0.1 - - [27/Jan/2011:07:38:06 --0500] [localhost/sid#2bfe38][rid#107cbc0/initial] (1) pass through /myProject/site/aboutUs



I guess the rewrite rule of the .htaccess file doesn’t work

If your rules doesn’t work, it’s Apache that throws the error. Yii’s errors look completely different and they tell you, that it was Yii who created the error message. You can also check Apache’s error.log to see, which page it tried to access and couldn’t find.

Some here reported problems with the default rewrite rule. Can you try to replace the last line with this?


RewriteRule ^(.*)$ index.php/$1 [L]

I replace the htaccess rewrite rule with


RewriteRule ^(.*)$ index.php/$1 [L]

but the error is the same




Not Found


The requested URL myProject/site/aboutUs was not found on this server



Hmm. Can’t really tell what’s wrong. You need to experiment with mod rewrite. Try different simple URLs in your browser and examine the mod rewrite log. The rule says pretty clear that anyhting not being a file or directory should be rewritten to index.php. Examine what happens if your remove the two RewriteCond lines (just for testing!). Also try to remove the enclosing <IfModule…> directives.

It’s very likely that it’s only a small issue somewhere. You will find it! ;)

Thnx for the answers ;)

I did everything that you tell me but I get the same error :(

Hi! after several days… :P

I read this and I can solve the problem :D

Regards

Can you explain, which information in that article helped you? I can’t find anything new there.

It is a bit strange :blink: … I agree with you “I can’t find anything new there too” but I did everything again and now It works! ???

Thnx for all ;)

Don’t forget the QSA flag if you want zii widget to work :)


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php)

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



B) interesting … plz Could you explain me about QSA flag and the relation with zii widgets??

10x

regards

i think i have not left a single stone unturned but object not found is my only output if type the url without index.php

more info found here:

scroll down to QSA|qsappend

http://httpd.apache.org/docs/2.3/rewrite/flags.html

Had problem with this as well. What finally worked for me is adding this in apache2/conf/httpd.conf. Obviously this is for a Windows machine.




<Directory "C:\Program Files\BitNami WAMPStack\apache2\htdocs\myapp">

	Options Indexes FollowSymLinks +Includes

	AllowOverride All

	Order allow,deny

	Allow from all

</Directory>



The important line is "AllowOverride All":

Apache conf file can come with default to "AllowOverride None". It needs to be changed to "AllowOverride All" to let apache read properly your .htaccess