I have my CodeIgniter install one path back from the public_html directory so its not in the root of my web folder.
Can someone suggest .htaccess code that will get rid of the index.php in the URL based on this?
I have tried a few in the past and they havent worked, im quite stumped.
Cheers,
I have tried the following code
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Have you put the index.php one folder back from public_html as well?
I would suggest not doing so, there should be no harm in making the index.php public, but well worth hiding the rest.
Put the index.php back under public_html and modify it like so:
Line 56:
$system_path = '../system';
Line 72:
$application_folder = '../application';
Of course if you have them in another folder then change the path accordingly.
EDIT:
Sorry I should note that afterwards your htaccess should look like this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
try adding
RewriteBase /public_html/
above the first RewriteCond.
but I'm not an .haccess wizard by any means.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
Related
I just copied a codeigniter project from one folder to another in my XAMPP htdocs. These two projects contain exactly the same code, they're just in different directories.
In the copied project, the default_controller works fine but none of my routes work.
my routes:
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['dashboard'] = 'dashboard';
The index file is located at localhost/project/www
If I go to localhost/project/www/dashboard, I get a 404.
But if I do this:
$route['404_override'] = 'dashboard';
Then the dashboard controller loads correctly when I go to localhost/project/www/dashboard (or any other path, which would give a 404, of course)
The problem is not in the .htaccess file, since it's just generic:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Like I said, the code has just been copied from one directory to another. Any ideas as to what is preventing my routes from working properly? Have I missed something?
EDIT
After setting the 404_override and removing it again, the routes magically worked again. Everything is fine.
If anyone could shed a light on why this has happened, that might help the next guy who gets in this situation. But for me, the problem is resolved.
OK, the problem was that I had used uppercase for the name of the copied project, but was trying to access it with lowercase on a system that discerns between these two.
So, stupid
i think problem is you were using doing like this
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
instead you try it
RewriteEngine On
RewriteBase /www/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
How to remove domainname.com/index.php/photos from the pyrocms URL. I tried to remove index.php from $config['index_page'] = 'index.php';. But it does not work. Can anyone help please. Is there anything i have to do during the installation time.?
You will have to use an .htaccess file in the root folder too (if you are using apache or php built-in webserver).
Here is the one I use: https://gist.github.com/taiar/2424263
Here is the reference from the oficial docs: https://ellislab.com/codeigniter/user-guide/general/urls.html
You need to write a .htaccess rule
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Hi I am trying to use CodeIgniter A3M.
I am trying to view the manage users and manage permission etc but keeps on saying error 404 I am the admin I have just created an account for my self.
This seems to be a problem with your CodeIgniter setup. All the links in A3M are already assumes that you have taken steps to remove the index.php from the path using .htaccess. You can read in the user guide on how to do that. In general you should have this in your .htaccess file in the root:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also check that you have all other settings set correctly according to A3M.
I think you must code .htacess file like this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Its working for me
My code .htacess
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond $1!^(index\.php|resource|system|user_guide|bootstrap|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L]
I know this question has been asked one thousand time. But I have problem applying it to my project however.
What I do: I have copied the following code (suggested by CI Docs) in .htaccess file in my application folder:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
PROBLEM: it does not work and it throws 404 or Internal Error. I also have tries creating new .htaccess file in my root folder, or copying the above code in system folder's .ht . none of them works. 404 or internal error are inervitable
paste the following code in your htaccess file inthe root folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
and the in the config.php file change the line with
$config['index_page'] = '';
please let me know if you face any problem.
Try this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
and in config.php
$config['index_page'] = '';
Thanks everybody. it is done. The problem was that I had not activated the APACHE rewire_module
Sorry if I wasted your time.
thanks
I have already worked in the CI. But this time when i remove the index file. I am getting 404 error. But i did everything correctly. Here is the settings i have done.
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/javascripts|files\/stylesheets|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /qrout/index.php/$1 [L]
Config File
$config['base_url'] = 'http://webscarlets.in/projects/';
$config['index_page'] = '';
I hope above settings are all correct. And i have tried added this 'qrout' folder in the base url still it's not working
Here is the website link
http://webscarlets.in/projects/qrout/welcome
Kindly guide me to solve this issue.
Thanks to all.
Try to use this condition .....ITs working for me
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
It looks like your rewrite condition is targeting js files and things like that. Those files don't need the index.php in their path. Only your Codeigniter files will.
I'd rework that conditional statement.