How to remove domainname.com/index.php/photos from URL - codeigniter

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]

Related

Codeigniter A3M Admin Controller

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]

Codeigniter Index file issue

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.

mod_rewrite for codeIgniter

Has anybody in the history of the internet and web development, been able to get rid of the "index.php" with mod_rewrite in codeIgniter.
I've been trying for several days now and nothing seems to work.
I'm using this one (in .htaccess file):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Not sure where I got it but it works for my codeigniter install, local and live. Don't forget to set $config['index_page'] = ''; in your config file.
For mod_rewrite use the following in your .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If your codeigniter instance is running in a subdirectory then use the rewrite base command before the RewriteRule
RewriteBase /subdirectory/
Then set
$config['index_page'] = '';
In the config file.
You might have your .htaccess file in the wrong place. CodeIgniter has a default .htaccess placed in the applications folder, which I mistakenly took for the one I should edit.
You actually need to create a new .htaccess under the root folder. So not code_igniter/applications/.htacces...but code_igniter/.htaccess
Hope this helps.
Yes, I configured it under Linux using the instructions from here. However, I configured it via httpd.conf instead of using .htaccess.
I have used the settings provided above and they always worked - unless I did not have mod_rewrite enabled.
If you are having issues check to ensure you have mod_rewrite enabled. If you do not it will not matter what you put into .htacess or your Apache config

CodeIgniter - Getting rid of the index.php in different circumstances

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]

How do I use mod_rewrite to provide RESTful URLs, hiding my script name?

I'm new to using mod_rewrite. Could some one tell me how to change this url
http://example.com/blog/index.html?page=1
to
http://example.com/blog/page/1
Thanks a bunch!
Kohei
RewriteEngine on
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html?page=$1 [L,QSA]
try the above lines in your .htaccess

Resources