Hiding Index.php Results In 403 Error

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?

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.

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

	),

);



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!