Welcome Guest, Not a member yet? Register   Sign In
suggestion for best htaccess
#1

[eluser]hcvitto[/eluser]
hi
after i few attempt i still haven't found the right htaccess for my app.
Here's the structure of the app (codeigniter is installed the default way):

CONTROLLERS folder
main.php (file contains all the functions)
admin (directory for the admin area)
-login.php (file for the login inside admin folder)


Here's what i'm using at the moment and it works partially, means i can't access subfolder..(unless i use index.php in the url)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app_labitta/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/main/$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>

what should i add to get to:

localhost/myapp/admin/login

and not to use:

localhost/myapp/index.php/admin/login ?

Thanks vitto
#2

[eluser]drewbee[/eluser]
Removing the index.php has been discussed many a times on this forum. Search, my man.

http://ellislab.com/codeigniter/user-gui.../urls.html

You will also have to edit a variable in the config.php file. It contains the value of 'index.php'
#3

[eluser]Rey Philip Regis[/eluser]
Hey...

Im not really good at this htaccess file. But this code works for me

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]

Good day.
#4

[eluser]drewbee[/eluser]
It is not just the htaccess. Their is a configuration variable in the config.php that should be removed as well.
#5

[eluser]Rey Philip Regis[/eluser]
Yah!

in the config i did it like this:

$config['index_page'] = "";
#6

[eluser]drewbee[/eluser]
Oh ok. You didn't mention that. Smile

Is everything setup correctly for you now?
#7

[eluser]hcvitto[/eluser]
ok
sorry, i didn't say that, too. i already cancelled 'index.php' in the config file.
My problem is i can't access subfolder. Everything is ok for the root but how do i get to the controllers->admin->login.php ?


My code alread works fine for the first level

VItto
#8

[eluser]drewbee[/eluser]
You create sub directories.

/root
/root/application/controllers/ <-- first level
/root/application/controllers/admin <-- second level

Within the admin directory, create a new controller for what ever its purpose may be IE manage_users.

So then,

/root/application/controllers/admin/manage_users.php

is accessed from

/admin/manage_users/<parameter>
#9

[eluser]hcvitto[/eluser]
hi drewbee
sorry but i didn't explain rightlySad

i meant i can access subdirectory if i use

localhost/myapp/index.php/admin/login

What i need is an htaccess that lets me use

localhost/myapp/admin/login (no index.php)

The htaccess i use now just lets me get to the root with no index.php...

localhost/myapp/main (this works)

Hope this is clearer..
Vitto
#10

[eluser]drewbee[/eluser]
Here is my htaccess. I also have the index.php removed and the subdirectories seem to work just well with this.

Do you have code igniter in a lower directory IE myapp?

Code:
Options +Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php


    RewriteEngine on

    # This will make the site only accessible without the "www."
    # (which will keep the subdomain-sensive config file happy)
    # If you want the site to be accessed WITH the "www."
    # comment-out the following two lines.
    # RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC]
    # RewriteRule ^(.*)$ http://site.com/$1 [L,R=301]
    
    # If a controler can't be found - then issue a 404 error from PHP
    # Error messages (via the "error" plugin)
    # ErrorDocument 403 /index.php/403/
    # ErrorDocument 404 /index.php/404/
    # ErrorDocument 500 /index.php/500/
    
    # You can also uncomment this if you know the IP:
    Deny from 192.168.1.1
    
    # If the file is NOT the index.php file
    RewriteCond %{REQUEST_FILENAME} !index.php
  
    # If the file/dir is NOT real go to index
    RewriteCond $1 !^(index\.php)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ myapp/index.php/$1 [QSA,L]




Theme © iAndrew 2016 - Forum software by © MyBB