Yii Framework Forum: Problem Hiding index.php, error: The requested URL /sc2/post/index.html was not found on this server. - Yii Framework Forum

Jump to content

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

Problem Hiding index.php, error: The requested URL /sc2/post/index.html was not found on this server. Rate Topic: -----

#1 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 29 April 2010 - 11:52 AM

I was extending the Yii Blog example with some other models.

When I try to enable the "Hiding index.php" feature explained in http://www.yiiframew...uide/topics.url

I added the .htaccess with this content

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


And this is the content of the urlManager

'urlManager'=>array(
			'urlFormat'=>'path',
			'showScriptName' => false,
			'urlSuffix' => '.html',
			'rules'=>array(
        		'post/<id:\d+>/<title:.*?>'=>'post/view',
				'replay/<id:\d+>/<title:.*?>'=>'replay/view',
				'ustream/<id:\d+>/<title:.*?>'=>'ustream/view',
        		'posts/<tag:.*?>'=>'post/index',
				'<view>'=>'site/page',
        		'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
				
        	),
        	
			
		),


Then I refresh the main index and when I try to go to the post index page ( http://localhost/sc2/post/index.html ) it says:

Not Found

The requested URL /sc2/post/index.html was not found on this server.

How can I resolve this bug?
Thank you very much, Emanuele.
0

#2 User is offline   jayrulez 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 348
  • Joined: 29-July 09

Posted 29 April 2010 - 12:34 PM

apache's mod_rewrite is turned off by default in wamp. Turn it on then try again.

I use this convenient setup

Options +FollowSymLinks
IndexIgnore */*
DirectoryIndex index.php

<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?url_rewrite_on=1&%{QUERY_STRING}
	RewriteRule ^$ index.php?url_rewrite_on=1&%{QUERY_STRING}
</IfModule>


...
'showScriptName'=>!(isset($_GET['url_rewrite']) && $_GET['url_rewrite']==1),
...


so index.php is only hidden when mod_rewrite is enabled or i explicitly type a url with this in it:
url_rewrite_on=1

if you do that and do not want anyone to explicitly try to manipulate hiding your index.php then make url_rewrite_on a random string that is unlikely to be guessed easily and reflect the change in your config.php and .htaccess
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";

python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]

ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}


You say Tomato, I say Tomato.
0

#3 User is offline   Onman 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 175
  • Joined: 26-December 09
  • Location:The Netherlands

Posted 29 April 2010 - 12:52 PM

I had some problems with this as well (I know hardly anything about the .htaccess contents), in particular with the code StErMi shows.
Somewhere I found the .htaccess below and this works for me.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
0

#4 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 29 April 2010 - 04:13 PM

I'm using LAMP and mod_rewrite is on. Like explained I'm using the same .htcaccess used in the Yii Official guide.
0

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,342
  • Joined: 12-October 09
  • Location:Croatia

Posted 30 April 2010 - 04:04 AM

There are similar discussion in this forum

On some configuration the last .htaccess line

RewriteRule . index.php


is not working, try to change it to

RewriteRule ^.*$ index.php

Find more about me.... btw. Do you know your WAN IP?
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