Codeigniter URLnot found - php

I am using Codeigniter framework in PHP. My website is on apache server. Path: /var/www/example.com/public_html
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
But still I am getting this error on accessing this page: www.example.com/test/wallet:
The requested URL /test/wallet was not found on this server.
SCREEN SHOT
When I use www.example.com/index.php/test/wallet, then it's working...

this is my .htaccess that works on both wamp and live linux server running Centos + Apache and Ubuntu +apache
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /path-to-code-igniter-directory/index.php/$1 [L]
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
I also made a video on how to do this here
https://www.youtube.com/watch?v=v-4VkR54vLU
(skip to 28:50 to see the .htaccess .I also put it in the description under the video)
hope that helps

problem is with your URL rewrite.
place this outside application folder
File name = .htacess
in side
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

I think all of your .htaccess setting are correct. I used #Nassim's solution.
Originally, Problem was with the configurations in apache2.conf file. I just set AllowOverride All in /var/www and activated rewrite on server by this command:
sudo a2enmod rewrite
Then I restarted my server: sudo service apache2 restart
Thanks to every1 for support.

Related

How to enable clean url? (VPS - Debian 9)

I have a VPS Server (Debian 9) and I want to have clean url.
If I enter for example "examle.com/example", this pops up an error "Internal Server Error" instead of showing the page.
What do I need to do to make this mistake disappear and show the page?
That style of URL (domain.tld/resource/path) would need to be handled via mod_rewrite (with Apache) or a try_files configuration with Nginx. Which you use depends on which HTTP server you're running, of course. Unless you're explicitly setup Nginx, it's probably Apache.
Assuming Apache (httpd) is being used- The easiest method to manage this is via a .htaccess file in your document root (where your index.php file lives). You'll need to verify mod_rewrite is enabled in your httpd configuration (usually found at /etc/httpd/httpd.conf or broken out further in a subdirectory).
There are a lot of configuration options available to you via mod_rewrite. Here's an example of one that will translate all URLs that do not point to an actual directory or file (thus preserving your ability to serve static content directly from httpd) to index.php:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
You would need to parse the URL to determine what to do with it (it will be contained within $_SERVER['REQUEST_URI']. Be sure to reference the mod_rewrite documentation if you need to make changes to this configuration.
try this I hope its help you
create a .htaccess file in your html folder and write blow code in it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
</IfModule>
or try below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
and the last one is for trailing slash at the end. (only use codes as your needs only).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
</IfModule>
more you can understand on
thanks.
I don't know why but all the time it shows me the error "500", even if I have empty .htaccess and basic files apache2.conf and 000-default.conf

deploy an php web site

I need help please.
I hosted a website designed with codeigniter on a remote server, but I can not access the pages.Jai as 404 page not found error.
Here is the contents of the config.php file
$ config ['base_url'] ='http://www.SitePhp';
$ config ['index_page'] ='';
Here is the content of the .htaccess file
Options -Indexes
RewriteEngine On
RewriteCond $1 !^(index\.php|assets/|robots\.txt)
RewriteRule ^ (. *)$ index.php/$ 1 [L]
Thank you.
htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
and shared host open mod_rewrite module.
$config['base_url'] ='http://www.SitePhp.com/';
will be
http://www.SitePhp.com etc.

Removing index.php from URL in CodeIgniter on Mandriva

I developed a project which uses CodeIgniter on Windows OS. The project works fine on XAMPP (Windows) and Linux hosting server (updated .htaccess on server to work). I want to use Open Mandriva for development purpose. If I run the controller using index.php, it works.
I tried many .htaccess rules examples, links. But controller is not loading.
I tried: Cannot remove index.php from CodeIgniter URL, CodeIgniter removing index.php from url and
this external link, and many other links.
.htaccess code on Windows machine
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
.htaccess code on Linux hosting server
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
Both are not working on Open Mandriva.
.htaccess path
/srv/www/html/ci/
The page gives:
404 error, and Object not found!
The file system path to my project is
/srv/www/html/ci/application/controllers/
and on browser:
localhost/ci/branch
Project works if I add index.php like
localhost/ci/index.php/branch
Is it having any relation with http server config? Do I need to install any package. Also I tried some commands for apache rewrite engine. But I get error as unknown command.
Check if rewrite engine is enabled.
If not, enable rewrite engine and restart server.
sudo a2enmod rewrite
sudo service apache2 restart
Go to
/etc/httpd/conf/httpd.conf - for Mandriva
/etc/apache2/apache2.conf - for Ubuntu
Change AllowOverride None to AllowOverride All
Code block:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
Restart Apache(httpd) service.
No changes required in config.php or anywhere else.
.htaccess code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Please try the following:
RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L,QSA]
Then, in config.php:
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
Please ensure that your .htaccess is located in the same directory as your index.php.

CodeIgniter can't remove /index.php/ from url [duplicate]

I have done this lots of time. But than also I am stuck here again (in a different server) and can not figure out what is the issue.
Completed htaccess editing
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /glt.me/CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /glt.me/CI/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
rewrite module is enabled (as per customer care perons says)
Error :
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, cgiadmin#yourhostingaccount.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Test this case :
http://glt.me/CI/test
http://glt.me/CI/index.php/test
This is the simple way and it works fine for removing index.php from your url
RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|css|js|lib|img|bootstrap|robots\.txt)
RewriteRule ^(.*)$ /manage/index.php/$1 [L]
instead of manage put your own application folder name.
Use following htaccess code to remove index.php from your codeigniter url
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]
Though your client confirmed the rewrite module is working, what don't you confirm it yourself, make a php file on the root of the project with the code below and try to browse the file.
<?php
if( !function_exists('apache_get_modules')){
echo 'Rewrite module not available';
}else{
if(in_array('mod_rewrite',apache_get_modules()))
echo 'Rewrite module enabled';
}
First check whether your apache is supporting mod_rewrite. If yes then add a .htaccess file. My codeigniter .htaccess file is:
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]
Finally in your config file, change your base_url, remove index.php from that if you have added.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
RewriteRule ^pages/.*$ http://localhost/test/? [R=301,L]
I wanted to contribute here as I was having trouble myself. I'm using IIS5.1 for development only (Highly not recommended!)
1- Make sure that you config.php file has:
$config['index_page'] = '';
2- My app is not on the root folder, it's at localhost/CodeIgniter/. I updated config.php to:
$config['base_url'] = 'http://localhost/CodeIgniter/';
3- You need Mod-Rewrite capabilities. This is embedded with most servers, but IIS5.1 needs a separate tool. I used: IIS Mod-Rewrite by micronovae. It's free as long as you use it on localhost
I put the following code (Instead of CodeIgniter, put the name of the folder):
RewriteEngine on
RewriteCond $0 !^/CodeIgniter/(css|js|swf|images|system|tools|themes|index\.php) [NC]
RewriteRule ^/CodeIgniter/(.*)$ /CodeIgniter/index.php/$1 [L]
If your application is at the root, the code you should use would be simply:
RewriteEngine on
RewriteCond $0 !^(css|js|swf|images|system|tools|themes|index\.php) [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
Hope it helps.
Only three steps are require to remove index.php from url in Codeigniter in WAMP environment.
1) Create .htacess file in parallel to application holder and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable “rewrite_module” of apache.
Restart your apache and its done.
Details : http://sforsuresh.in/removing-index-php-from-url-of-codeigniter-in-wamp/

How to integrate codeigniter website from live to local server

I have a website source code which is built in codeigniter. I am trying to setup it into local wamp server but not working properly.
I have done following things:
Create a database UTF-8 with database name "fc2" and import live server database.
Configure aplications/config/config.php by setting base_url.
Configure aplications/config/database.php by set databse host,username,password and database name.
But its not working. (Screen Shot attached).
.htaccess file looks like this
Please help me for this issue.
Thanks in advance
the problem I think is with the htaccess. Try this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /FOLDER_NAME/index.php?/$1 [L]
change FOLDER_NAME with the name of the local directory.
check whether you have put the base url in the config.php file with "http://".If not put "http://" and check
Please try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder_name/index.php?/$1 [L]
Also check if php installed properly in the stack.
Maybe reinstalling the WAMP stack might help.
Alternately I would be curious to check maybe in XAMPP to see if its something with the wamp.
try in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^sys.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^app.*
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>
assumming that index.php is your index page.
and sys is your system folder and app is your application folder.
and change in config.php
$config['index_page'] = '';

Categories