1

After removing "index.php" from URL using instructions described here,
cPanel sub-folder is requested when I call a codeIgniter controller which has same name as sub-folder.

Controller and sub-folder name is "sites". So, when I request

example.com/sites

Instead of requesting controller example.com/index.php/sites, it requests sub-folder "sites".

It can be fixed by deleting sub-folder or renaming the controller, BUT I want to know if there is any other solution to resolve this issue.

Thank You!

1

1 Answer 1

1

You can do that via htaccess Rules.

Try this rule:-

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
// Below line will controller instead of directory
RewriteRule ^sites/?$ index.php/sites [L]

OR

RewriteCond %{REQUEST_URI} !^/sites
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]

Hope it will help you :)

Sign up to request clarification or add additional context in comments.

5 Comments

If it is useful then accept the answer so future visitor can find it as useful :)
Is it a good practice to remove #RewriteCond %{REQUEST_FILENAME} !-d to make it generic? To ignore sub-directories and send request index.php every time.
It's not ignoring sub directories. check this link for more detail:- stackoverflow.com/a/34875835/4198099
In that answer you said "-d (is test string a valid directory)". Doesn't that mean, if we remove this than it will ignore sub-directories? Thank you!
Okay. Now I am getting your question. Yes you are correct. If we remove it then it will ignore sub-directories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.