Yii Framework Forum: Hiding Index.php Results In 403 Error - Yii Framework Forum

Jump to content

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

Hiding Index.php Results In 403 Error Rate Topic: -----

#1 User is offline   FrankW 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 07-December 12

Posted 07 December 2012 - 01:09 PM

I've been trying to hide index.php, following the guidance of numerous and helpful posts, in the URL but have been unsuccessful. My setup is as follows:

  • VirtualBox Ubuntu Server VM (Host is Windows 7)
  • Using a shared folder on host
  • webapp is a sibling to framework folder
  • mod_rewrite is enabled


Webapp runs fine unless I want to hide the script name. When using the following .htaccess config, I get a 404 error (URL not found):

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on
RewriteBase webapp
# 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


Some other posts discussed the need to set some of the apache configs in /etc/apache2/default as follows:
<Directory /var/www/>
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>


Doing this actually results in a 403 error (forbidden access).

Anyone have any suggestions?
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,082
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 07 December 2012 - 03:35 PM

could be permissions check if you have appropriate permissions
0

#3 User is offline   FrankW 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 07-December 12

Posted 07 December 2012 - 08:23 PM

View Postalirz23, on 07 December 2012 - 03:35 PM, said:

could be permissions check if you have appropriate permissions


Usermod access was granted, if that is what you are referring to, and write access has been allowed. in the /var/www Directory setting, if I change AllowOverride to All instead of None to allow the .htaccess file to be used, then I get the 403 error.
0

#4 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,082
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 08 December 2012 - 07:05 AM

can you post your config/main.php code
0

#5 User is offline   FrankW 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 07-December 12

Posted 09 December 2012 - 02:30 PM

View Postalirz23, on 08 December 2012 - 07:05 AM, said:

can you post your config/main.php code


Sorry for the delay in my reply. Following is my config code (pretty standard):

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My Website',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		'admincontrol',
                'usercontrol',
                'content',
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'pass',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		
	),

	// application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		// uncomment the following to enable URLs in path-format

		'urlManager'=>array(
			'urlFormat'=>'path',
                        'showScriptName'=>false,
                        'caseSensitive'=>false,
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
                /*
		'db'=>array(
			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
		),
		*/
		// uncomment the following to use a MySQL database

		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=db',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => 'root',
			'charset' => 'utf8',
		),

		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
);

0

#6 User is offline   FrankW 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 07-December 12

Posted 11 December 2012 - 02:03 PM

I finally solved this. alirz23 was correct early in the topic when he proposed that it was a permissions issue. I had misunderstood what he was referring to. I fixed the access to the .htaccess file and it is now working.

Thank you!
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