Forum Moderators: phranque

Message Too Old, No Replies

htaccess file not working

         

mooger35

3:13 pm on Oct 27, 2010 (gmt 0)

10+ Year Member



Hey,

I'm playing around with a new framework (codeigniter) and I'd like to clean up my url. Seems simple enough but for some reason it's just not working.

url format:
localhost/site/index.php/page

I'm trying to remove index.php

I'm using a windows machine and have installed apache 2 through the easyphp instal.

I've uncommented the load mod
LoadModule rewrite_module modules/mod_rewrite.so


and I've changed the allowoverides to all... and I have restarted apache numerous times.
<Directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
Allow 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.
# ======================================================
# ! DO NOT CHANGE THIS LINE AND THE FOLLOWING ONES !
# DocumentRootDirectory
<Directory "${path}/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org...]
# for more information.
#
Options FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>


Here is the htaccess file I'm using...
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]


Some help? Thanks.

jdMorgan

3:38 pm on Oct 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your rule rewrites requests for URLs which do not resolve to physical files or directories to 'forward' these requests to your /index.php script's filepath.

Therefore, it does not 'remove index.php' and it does not affect the existing liked URLs in any way.

Try a search on this site [google.com] for "remove index.php RewriteCond THE_REQUEST" for hundreds of threads on this subject.

Also, since you apparently have server config-file access, you could put the ".htacess code" into the config file's <Directory> container after you get it debugged for a good improvement in efficency plus a small boost in security.

Finally, think carefully about passing *all* requests to your script as you have done here. There is usually no reason to pass requests for static resources like robots.txt, sitemap.xml, /w3c/p3p.xml, labels.rdf, or any images, css files, JavaScript files, documents, or multimedia files to your script, and excluding them from your rewriterule would save a minimum of two and a maximum of four (very CPU-intensive) disk filesystem reads for each and every HTTP request so excluded. In addition, excluding your error page for 500-Server Errors can prevent un-debuggable problems in the future. Of all error pages, the argument for making the 500 error page a simple, static page is most compelling.

Jim