Solved

how remove index php from url in codeigniter using htaccess

Posted on 2014-03-03
4
4,309 Views
Last Modified: 2014-03-03
Hi there,

I am currently using codeIgniter 2.1.4,  

I am aware that you can remove the 'index.php' in the url with a mod rewrite using the htaccess file.

However I do not know how to go about doing it.


Can anyone offer a solutions.

I have attached the project that I am working on, so please take a look.

Kind Regards
0
Comment
Question by:smaids123
  • 2
4 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 500 total points
ID: 39899942
Yes, you can easily remove index.php from your app.  Do you use linux or windows?

For that you need to enable "RewriteEngine on"  & create the below instrcution way of .htaccess file

RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/

#RewriteBase /staging/

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L] 

Open in new window

0
 
LVL 14

Expert Comment

by:shobinsun
ID: 39899953
Hi,

1.Create your htaccess file
2.Set $config[‘index_page’] to an empty (config.php)
3.string Set $config['uri_protocol'] = 'REQUEST_URI'; (config.php)

htaccess file:

Options -Indexes
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

#When your application folder isn't in the system folder

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Hope this will help you.

For more info:

http://taggedzi.com/articles/display/codeigniter-2-htaccess-and-friendly-urls

Regards,
Shobin Markose.
0
 

Author Closing Comment

by:smaids123
ID: 39900108
Thanks a lot
Now I can get on with my project :)
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 39900120
I hope you have followed to remove in config.php  , $config[‘index_page’] to an empty (config.php)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now