-1

My CodeIgniter project is placed inside sub-folders and I want to hide those two sub-folders with .htaccess.

Everything is working fine but my current URL looks like this:

example.com/folder1/folder2/ci_project/class/function/$id

I want this to be:

example.com/class/function/$id

Now, I am using this simple .htaccess code in order to remove the index.php from URL:

Options +FollowSymLinks
RewriteEngine on

# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Any Ideas?

when i use the following code in htaccess file inside folder1/folder2/ci_project, it does hide the sub directories but i get the error "Object not found"

RewriteCond %{REQUEST_URI} !^/folder1/folder2/ci_project/

RewriteRule ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]

SeanDance
  • 1
  • 2

1 Answers1

0

Move your current .htaccess file from your ci_project/ to the root of domain, and replace these code inside it:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on

    RewriteCond $1 !^(robots\.txt|favicon\.ico|public)
    RewriteRule ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]
</IfModule>

In this case, you should place your public files in a folder like public at the root of the domain.

You should add other folders (like public) to RewriteCond if you don’t want them to be treated by RewriteRule.

If multiple application are exist in the same domain, you might want to consider this option:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]
</IfModule>
Hashem Qolami
  • 97,268
  • 26
  • 150
  • 164