Welcome Guest, Not a member yet? Register   Sign In
Can't remove index.php from URL
#1

[eluser]João Ramos[/eluser]
I'm running Apache natively on my Mac and followed the steps on the "Removing the index.php file" wiki article. I also made sure my Apache uses the mod_rewrite module and accepts needed .htaccess directives, as according to the Mod rewrite wiki article as well.

However, I can't still load controllers without having to insert the "index.php" on the URL. Unfortunately, I'm too rookie to understand how to properly debug this or how to give you any more detailed information. Can you guys help me out with this?
#2

[eluser]CroNiX[/eluser]
Please do a search for "htaccess" on this site. This is probably the most frequently asked question here and there are many, many examples and suggestions in the forums already.
#3

[eluser]João Ramos[/eluser]
Obviously, I did it before posting this: I tried different .htaccess setups and edits. Like I said, I'm too rookie to understand how to deal with this kind of rounting/rules and I don't even know how to properly explain in detail why I can't just use my app without the /index.php/ on my URL.
#4

[eluser]CroNiX[/eluser]
Well, no, it's not obvious you tried. Many people come here and just ask questions without looking first, or reading the user guide.

Try this .htaccess, and place it at the same location as index.php:
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

The next question is: How are you writing your urls, like in anchors? Manually or using some of the URL Helpers?

I have a feeling it is how you have the apache server set up though. Macs have most of the stuff disabled and you have to fudge with the apache conf.

Make sure your apache conf has these lines or you can't rewrite properly:
Quote:Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
#5

[eluser]InsiteFX[/eluser]
A quick way to test if your .htaccess file is working it to place TEST at the top of the file if it's working you will get a server 500 error.
#6

[eluser]João Ramos[/eluser]
Thanks for you attention, guys. However, I must be doing something really wrong, as it keeps giving me Not Found errors (even by using TEST] on top of the .htaccess file, which may suggest httpd.conf is messed up?). In fact, I'm almost sure I'm copy/pasting the httpd.conf instructions you gave me on the wrong section of my httpd.conf. Here's my httpd.conf (I know I shouldn't use URLs, but it seems it's too many characters to paste here and the forum says it can't write files to disk when I attach files): pastie.org/private/ptoymg41ypgm5xafzyf7q.
#7

[eluser]InsiteFX[/eluser]
Line 285 change to AllowOverride All
#8

[eluser]João Ramos[/eluser]
Thanks, but still printing 404 Sad
#9

[eluser]Mody[/eluser]
I have been facing this problem and its never working on my Ubuntu XAMPP, just because its http://localhost/ or http://ipaddress.
the htaccess is working on Windows xampp or any domain name but not on my ubuntu when using localhost or ipaddress
#10

[eluser]skcin7[/eluser]
Hey there. Here is the full contents of my .htaccess file (which removes "index.php" from the URL)

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

    #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]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    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>




Theme © iAndrew 2016 - Forum software by © MyBB