0

I am using codeigniter I want to rewrite index.php from urls.

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

when I use this code in my .htaccess index.php not removing.

but when I manually remove index.php from urls it works.

4 Answers 4

3

Complete this by removing the 'index.php' and replace with '' in your config/config.php.

That should be the second key created in the file. This will change all base_url() and site_url() functions on your site.

Sign up to request clarification or add additional context in comments.

Comments

0

when i use this code in my .htaccess index.php not removing.

Those rules only route requests to an index.php, it doesn't do anything about "removing" it. That's up to the links that you generate in your own content. If for some reason, you need to handle external links and want to redirect the client to the new URL with the index.php missing (like a Google indexing bot), then you can do this:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php/([^\ ]+) 
RewriteRule ^index.php/ /%1 [L,R=301]

Comments

0

Change $config['index_page'] = 'index.php'; in config.php to $config['index_page'] = '';

Comments

0

AllowOverride All

Ensure allow override directive exists in apache configuration for the directory section. This enables .htaccess file to be read if located within the specified directory.

Eg.

<Directory /var/www>
AllowOverride All
</Directory>

http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

Comments

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.