Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] NEWBIE - Problem removing index.php from url
#1

[eluser]lollylegs[/eluser]
Would be grateful if someone could tell me where I'm going wrong as I'm pretty new to this rewrite caper.
Regards Marea
Australia

Both my index.php and .htaccess files are directly below /codeigniter

MY PROBLEM :question:
The requested URL /blog/ was not found on this server.


My path:
v:\www\apache\htdocs\codeigniter

My .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$l [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$l [NC,L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

My index.php
&lt;?php
/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
| By default CI runs with error reporting set to ALL. For security
| reasons you are encouraged to change this when your site goes live.
| For more info visit: http://www.php.net/error_reporting
|
*/
error_reporting(E_ALL);

/*
|---------------------------------------------------------------
| SYSTEM FOLDER NAME
|---------------------------------------------------------------
|
| This variable must contain the name of your "system" folder.
| Include the path if the folder is not in the same directory
| as this file.
|
| NO TRAILING SLASH!
|
*/
$system_folder = "system";

/*
|---------------------------------------------------------------
| APPLICATION FOLDER NAME
|---------------------------------------------------------------
|
| If you want this front controller to use a different "application"
| folder then the default one you can set its name here. The folder
| can also be renamed or relocated anywhere on your server.
| For more info please see the user guide:
| http://ellislab.com/codeigniter/user-gui..._apps.html
|
|
| NO TRAILING SLASH!
|
*/
$application_folder = "application";

/*
|===============================================================
| END OF USER CONFIGURABLE SETTINGS
|===============================================================
*/


/*
|---------------------------------------------------------------
| SET THE SERVER PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full-server path to the "system"
| folder in order to reduce the possibility of path problems.
| Note: We only attempt this if the user hasn't specified a
| full server path.
|
*/
if (strpos($system_folder, '/') === FALSE)
{
if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
{
$system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
}
}
else
{
// Swap directory separators to Unix style for consistency
$system_folder = str_replace("\\", "/", $system_folder);
}

/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT - The file extension. Typically ".php"
| FCPATH - The full server path to THIS file
| SELF - The name of THIS file (typically "index.php)
| BASEPATH - The full server path to the "system" folder
| APPPATH - The full server path to the "application" folder
|
*/
define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION)Wink;
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ($application_folder == '')
{
$application_folder = 'application';
}

define('APPPATH', BASEPATH.$application_folder.'/');
}

/*
|---------------------------------------------------------------
| LOAD THE FRONT CONTROLLER
|---------------------------------------------------------------
|
| And away we go...NOT ME!!!!!! 8-/
|
*/
require_once BASEPATH.'codeigniter/codeigniter'.EXT;

/* End of file index.php */
/* Location: ./index.php */

My Relevant httpd.conf section

DocumentRoot "C:/www/apache/htdocs"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/www/apache/htdocs">
Options Indexes Includes FollowSymLinks Multiviews
AllowOverride AuthConfig FileInfo
Order deny,allow
Allow from all
</Directory>
#2

[eluser]narkaT[/eluser]
instead of this:
Quote:# <Directory “C:/www/apache/htdocs”>
Options Indexes Includes FollowSymLinks Multiviews
AllowOverride AuthConfig FileInfo
Order deny,allow
Allow from all
</Directory>

try this:
Code:
<Directory “C:/www/apache/htdocs”>
  Options Indexes Includes FollowSymLinks Multiviews
  AllowOverride All
  Order deny,allow
  Allow from all
</Directory>

'AllowOverride All' is needed in order to get mod_rewrite working Wink
#3

[eluser]tonybianco[/eluser]
I'm having the exact same problem. I think the only difference is that I'm using MAMP as I have a mac. So it uses localhost:8888 as it's base. I put the .htaccess file in the CI directory (the same level as index.php) as nothing is happening. I just keep on getting:
Quote:The requested URL /index.php/$l was not found on this server.

My .htaccess file

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$l [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$l [NC,L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

What am I doing wrong?
#4

[eluser]lollylegs[/eluser]
Hi Tony

The error is in your RewriteRule's it should be /index.php/$1 (that is numerical 1 not letter l)

Being a newbie myself this is the first time I have been able to help someone.

Thanks for giving me the opportunity.

Regards
Marea
Australia
#5

[eluser]smidiod[/eluser]
Worked great for me, too. A ready-made solution rather like CI! ;-)




Theme © iAndrew 2016 - Forum software by © MyBB