Yii Framework Forum: Problems hiding index.php of the path - Yii Framework Forum

Jump to content

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

Problems hiding index.php of the path Rate Topic: -----

#1 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

  Posted 26 January 2011 - 04:25 PM

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
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 27 January 2011 - 03:04 AM

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....od_rewrite.html
0

#3 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

Posted 27 January 2011 - 07:47 AM

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
0

#4 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 28 January 2011 - 04:15 AM

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]

0

#5 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

Posted 28 January 2011 - 07:45 AM

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

0

#6 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 29 January 2011 - 04:07 AM

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! ;)
0

#7 Guest_sidebar_*

  • Group: Guests

Posted 02 February 2011 - 11:13 AM

Another quick tip:

Ensure that Apache is also configured for Mod Rewrite.

LoadModule rewrite_module modules/mod_rewrite.so shouldn't be commented.
(which was the case for my local apache server.)
0

#8 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

Posted 10 February 2011 - 08:32 AM

Thnx for the answers ;)

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

#9 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

Posted 15 February 2011 - 09:14 AM

Hi! after several days... :P

I read this and I can solve the problem :D

Regards
0

#10 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 16 February 2011 - 03:45 AM

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

#11 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

Posted 16 February 2011 - 07:22 AM

View PostMike, on 16 February 2011 - 03:45 AM, said:

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 ;)
0

#12 User is offline   Revelis Luc Bonnin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 23-May 11
  • Location:Earth

Posted 15 August 2011 - 08:35 AM

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]

0

#13 User is offline   ClaCS 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 21-January 11

Posted 16 August 2011 - 04:55 PM

View PostRevelis Luc Bonnin, on 15 August 2011 - 08:35 AM, said:

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
0

#14 User is offline   sonam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 10-September 11

Posted 24 October 2011 - 09:16 AM

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
0

#15 User is offline   maxlight 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 12-November 11

Posted 25 December 2011 - 08:45 PM

more info found here:

scroll down to QSA|qsappend
http://httpd.apache....rite/flags.html

View PostClaCS, on 16 August 2011 - 04:55 PM, said:

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

10x


regards

0

#16 User is offline   OptimusRay 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 06-April 12

Posted 06 April 2012 - 12:12 PM

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>

0

#17 User is offline   teher811 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 44
  • Joined: 25-January 10
  • Location:Glasgow, Scotland, UK

Posted 04 May 2012 - 01:09 PM

View PostOptimusRay, on 06 April 2012 - 12:12 PM, said:

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
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