Welcome Guest, Not a member yet? Register   Sign In
Please Help to remove index.php from url
#1

[eluser]GeLiNa[/eluser]
Hello, I'm a newbie in CodeIgniter. I followed the user guide, but I can't remove index.php from url.

Condition:
1. I use Wamp Server.
2. My Base url is: http://localhost/trial/
3. My CI url is: http://localhost/trial/application/
4. I set $config['base_url'] = 'http://localhost/trial/'; and $config['index_page'] = ''; in config.php
5. I put the .htaccess file in the same folder with index.php (http://localhost/trial/)
6. My .htaccess file content:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

and I've also tried some other .htaccess which I find in this forum, like:
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
or any toher else.

I also tried to add this like some people in this forum suggest
Code:
RewriteBase /trial/


But the result is always same, and it happened even if I include the index.php in the url as long as the .htaccess file is there:
Code:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

I've tried many things in this forum, but none of them resolve it. Can someone help me, please?

#2

[eluser]Tejas D[/eluser]
So,

trial is your folder and structure may like this.


-localhost
-trial
-application(rest all folders)


create .htaccess file and save it in your trail folder with below contents-

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /trial/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    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>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>



Also,
- make sure mod_rewrite module is enabled.
- $config[‘index_page’] = ‘’; in config.php

#3

[eluser]GeLiNa[/eluser]
Hello Tejas D, thank you for helping.

I've tried the solution you give, and there is a progress. It is now working for localhost/trial/ (without index.php), thanks to you, but if I continue with localhost/trial/category (to access category controller), I don't get the result I want, but I get localhost/ (but the url is written: localhost/trial/category)
#4

[eluser]Unknown[/eluser]
.
#5

[eluser]GeLiNa[/eluser]
Hello Tejas D, It is now working properly after I restart my Wamp Server. Thanks a lot.


Best Regards,

GeLiNa
#6

[eluser]Tejas D[/eluser]
Hi Gelina

Good to see some progress.

This is my demo code of httpd.conf.(I am using LAMP)

Code:
ServerName localhost

NameVirtualHost 127.0.0.1:8000
Listen 127.0.0.1:8000
Listen 127.0.0.1:25
<VirtualHost 127.0.0.1:8000>
  DocumentRoot "/var/www/"
  <Directory "/var/www/">
*   Options Indexes FollowSymLinks MultiViews
*   DirectoryIndex index.php
*   AllowOverride All
    Order allow,deny
    Allow from All
  </Directory>
</VirtualHost>

-> Check for the appropriate file or the file where you will find above structure in WAMP.
-> Add or Edit the lines indicated by *. or simply copy those 5 lines which are under directory tag
to your file.
-> use your configuration for DocumentRoot and inside Directory tag(as I have "/var/www/").
-> Also, restart your server(WAMP) after editing files.

Hope, this will work.



#7

[eluser]Tejas D[/eluser]
Hi Gelina

Good it is working properly,after you restarted WAMP.

Sorry, I didn't saw your latest post, saying working now.

So, Ignore my that httpd.conf post.(But i mentioned in that to restart your WAMP Smile ).

Regards,
Tejas



#8

[eluser]GeLiNa[/eluser]
Thank you, Tejas. Glad to have someone helpful like you :-)

God bless you.
#9

[eluser]ahmed.alsiddig[/eluser]
hi guys
removing index.php didnt work for me

i did all your steps but nothing

please help

Code:
$config['base_url'] = 'http://localhost/altayyah/';





Theme © iAndrew 2016 - Forum software by © MyBB