0

My apps url is

http://localhost/myapp/admin/index.php/projects

and I want to rewrite it as

http://localhost/myapp/admin/projects

I followed user guide

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

for this but not work for me.

3
  • RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] Commented Jun 22, 2012 at 6:57
  • Did you remove index.php from the index_page variable in the config file as well? Commented Jun 22, 2012 at 6:59
  • possible duplicate of Remove index.php from URL Commented Aug 4, 2012 at 19:43

2 Answers 2

0

Please follow these steps:

1- If you work on localhost please enable mode_rewrite in php.ini

2- Create a .htaccess file under project folder and paste this (please change 'project' to your project folder name):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /project/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /project/index.php
</IfModule>

3- Edit this line at application/config.php:

$config['index_page'] = "";
Sign up to request clarification or add additional context in comments.

Comments

0

Thank /* ActuallyMAB */: Your code actually works. The above code works on localhost (WAMP Server on windows). If you have placed your codeigniter project in some folder such as your directory structure looks like:

C:\wamp\www\proposal

So, You have to replace

RewriteRule ^(.*)$ /project/index.php/$1 [L]

to

RewriteRule ^(.*)$ /proposal{or your folder name}/index.php/$1 [L]

if this is not the case with your project {you have put your codeigniter directly into www folder}, then remove the folder name from the above code as it looks like;

RewriteRule ^(.*)$ /index.php/$1 [L]

also do not forget to change

$config['index_page'] = 'index.php';

to

$config['index_page'] = '';

in your config folder {config.php}

I hope others have also provided the same answer, but since the above code works in my project and i felt to provide some details too.

1 Comment

I am sorry to ask this: I can not login to my website when i implemented the above code. I guess data is not being pulled or what is the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.