0

My current Url look like this :

http://www.example.com/testdesign/index.php/tasks

And I need it to redirect to:

http://www.example.com/testdesign/tasks

My codeignitor root .htaccess file contains

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
   RewriteCond %{REQUEST_URI} !/system/.* [NC]
   RewriteRule (.?)index\.php/(.*) /$1$2 [R=301,NE,L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

mod_rewrite is enabled on my apache server.

In my config file :

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

when I run it from the localhost,it shows me like this:

http://www.example.com/tasks

But I want to remove index.php only not subdomain.

I know it might be a very small problem, but I'm unable to find the error.

Would you please give me proper suggestion about it?

Any kind of help would be highly appreciated.

Thanks in advance.

Jay Kareliya
  • 760
  • 7
  • 21

4 Answers4

0

Just Try this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /testdesign

# Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

# Prevents user access to the application 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]
</IfModule>

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

It works even if you did not configure your uri_protocol and base_url.

0

Try like this. In your .htaccess file

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
   RewriteCond %{REQUEST_URI} !/system/.* [NC]
   RewriteRule (.?)index\.php/(.*) /$1$2 [R=301,NE,L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)/testdesign$ index.php/$1 [L]
</IfModule>

OR

Set $config['base_url']='http://www.example.com/testdesign/'

Then Run www.example.com/testdesign/tasks

Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19
0

You should try to use base_url() instead of site_url(). See, even when your rewrite configutarion is correctly setted, if you are using site_url() the index.php file will be included.

See more in the docs: site_urlr(), base_url()

You also should leave blank the index_page config in your config/config.php

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php'; 
ShutUpMagda
  • 171
  • 2
  • 12
0

Replace below code to your .htaccess code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Sujal Patel
  • 2,444
  • 1
  • 19
  • 38