Welcome Guest, Not a member yet? Register   Sign In
Need help with mod_rewrite!
#1

[eluser]Unknown[/eluser]
Hi

I've been trying to remove the 'index.php' part of my url while working with codeigniter. I can't seem to get it working, and it feels like I've been trying everything.

Can anyone help me?

this is my .htaccess:

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

    #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>

    <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>

and this is my config:

Code:
$config['base_url'] = 'http://localhost/robbin/ci/';
$config['index_page'] = '';

I have a view called members, and when I go to http://localhost/robbin/ci/index.php/site/members I can see it working but when I go to http://localhost/robbin/ci/site/members or http://localhost/robbin/ci/members I just get sent to the very root (http://localhost/xampp/).

Why is that?

I'd really love some help with this!
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

Is mod_rewrite enabled?

If it is, first of all (if you're able to), I would recommend you add the Web root directory for your application as a virtual host. Then you can edit your hosts file, and add something like:

Code:
mysite.imaginarydomain.com    127.0.0.1

Then you should be able to access your site using the URL above.

After that, this .htaccess file should do the trick.

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/(system|application|html_store)
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
#3

[eluser]Unknown[/eluser]
Hey, and thank you for welcoming me Smile

Yes, mod_rewrite is enabled.

You kinda lost me on adding a application as a virtual host, I'm terribly bad at this kind of stuff. Would you mind explaining it?

#4

[eluser]TheFuzzy0ne[/eluser]
Perhaps this will help? http://austinpassy.com/tutorials/setting...windows-7/




Theme © iAndrew 2016 - Forum software by © MyBB