-1

I need to hide/remove the index.php in the URL's of my application in CodeIgniter. I proved something i saw in a tutorial on youtube but in didn't work, the solution was writing something in my .htaccess.

Here's my repository:

https://github.com/ashcrimson/CodeIgniter/tree/master/CodeIgniter

And here you have my .htaccess file:

Options FollowSymLinks
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.")$ index.php?/$1 [L]
</IfModule>

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

http://pastebin.com/eCU5UgL0

8
  • Have you enabled mod_rewrite? Commented Sep 2, 2016 at 22:09
  • Yes, it's enabled. Commented Sep 2, 2016 at 22:31
  • Try when RewriteBase is added too. If in root of public_html -> RewriteBase / or if in some subdirectory -> RewriteBase /subdir/#don't forget ending slash Commented Sep 2, 2016 at 22:38
  • 1
    Don't simply dump links to your code. Please take the time to cut & paste the relevant code into your OP. See: stackoverflow.com/help/mcve Commented Sep 2, 2016 at 22:48
  • 1
    That's not acceptable... everyone else seems to be able to figure it out. When you use links, they eventually go dead and the posting becomes useless to others. Commented Sep 2, 2016 at 22:51

1 Answer 1

0

Below is my .htaccess to take out index.php from the URL.

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

The RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] should be ^(.*)$ not ^(.")$

Check the rule. Wish it helps.

^(.*)$ ./index.php/$1 represents whatever you requested, redirect it to the index.php file which can handle the passing parameters.

In regex, . means anything; * means 0 or more times.

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

1 Comment

This did it. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.