eror .htacces Codeigniter on webserver - php

I have code .htacces that familiar when you using Codeigniter like this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
But its not work. like this.
When I delete this .htacces, the code running well. I have been check mod_rewrite on apache is enable. I'm confused, need help please

TRY THIS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /projectname
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Note: projectname is your root folder name

Even though you have mod_rewrite enabled, there is still a setting that can prevent .htaccess from working.
Check your httpd.conf file and make sure that in the directory settings that
AllowOverride None
is changed to
AllowOverride All
If you need more details than that, just ask! I've kept this very brief.

Try this in .htaccess
RewriteEngine on
RewriteBase /ci
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and in application/config/config.php
$config['index_page'] = ''; // make it empty.

Related

How to remove index.php from URL in CodeIgniter using .htaccess

I know this question is asked many times before and I've gone through most of them already but couldn't find a solution. I've tried most of the answers given here, here and in CodeIgniter official documentation. And restarted apache each time. It didn't work for me. mod_rewrite is already enabled in my apache server.
Weird thing is, I've a working example for WAMP (in my laptop):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /project/index.php
</IfModule>
It works perfectly in WAMP, but it doesn't work in LAMP. Any kind of help is appreciated.
Please use below code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I have used this and it is working.
Try Below code in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ROOT DIRECTORY NAME/
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<Directory "/path/to/document/root/">
AllowOverride All
Allow from All
</Directory>
Just like this......
.htaccess inyour root directory with following code..
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Set configuration in application/config.php as follows..
$config['base_url'] = 'http://domain_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I made it working with the help of following .htaccess code:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
And I updated <Directory /var/www/> section of /etc/apache2/apache2.conf file with:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
It solved all problems and now it works fine.
here it is my approach:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
And also in config.php replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
and also in the same file replace
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"

How to skip index.php in URL rewriting?

I have set WAMP up and running without too much hassle. But thing is I could not skip past index.php in my URL (localhost/index.php/login is working but localhost/login is not working).
Anyway my project is based on CI framework and I was using vagrant previously for hosting same project and which is working perfectly for this case. I have checked that the rewrite_module on for Apache and here it is my .htaccess file.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Please help me out from here.
First of all go in your project myproject-application->config.php
replace line no. 29
From
$config['index_page'] = 'index.php';
To
$config['index_page'] = '';
Then add .htaccess file on your root folder.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Try this .htaccess file code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Not Able to remove "Index.php" from URL in codeigniter

I am new in codeigniter and i am trying to remove index.php from URL in Codeigniter but not able to do this.
I wrote code in my .htaccess file-
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
My Apache mod_rewrite is enable.
But still got 404 error when i am trying to access any controller without using index.php.
Please help.
Thanks.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
</IfModule>
Is the code I'm using, it works on every hosting platform I've used it on.
This should help you,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
check this code of htaccess file.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
you can find your answer refference here
My .htaccess file is not working
moreover can you share your base url with us? as this error may be due to wrong baseurl set.

htaccess - using codeigniter framework

I search a lot websites and lots of links and i follow the same for enable htacces in wamp but facing the problem and now as default use index.php even when i run the page without index.php its not working even msg comes page not found on server i already enable in apache module also the httpd.conf file remove the # sign from rewrite module and i use the mention below code in htaccess file for codeigniter for suggestions i share htaccess code
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
please suggest so i can solve this issue on wamp server
Try this code in your htaccess :
RewriteEngine On
RewriteBase /my_project_name/
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
Try this
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]

Removing index.php of codeigniter on local

I'm trying to remove index.php,in my localhost, but it seems doesn't working,its on http://localhost/testing.
I put .htacces in 'testing' directory under the htdocs.
LoadModule rewrite_module modules/mod_rewrite.so
at Apache/conf also already unchecked.
Here my .htaccess:
RewriteEngine On
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /testing/index.php/$1 [L]
Here my config:
$config['base_url'] = "http://localhost/testing";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
When I access login controller, it's not found.
Not Found
The requested URL /testing/login was not found on this server.
I really don't know what to try next. Any help would be appreciated.
Try this :-
Config.php :-
$config['base_url'] = 'http://localhost/testing/';
$config['index_page'] = '';
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Your htaccess should be like
RewriteEngine On
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
There's no need to append /testing/ since RewriteBase already takes care of that.
basically the index.php is included in all URLs:
we can remove this using .htaccess with a simple rules. following is an example of such a file, using the "negative" method in which everything is redirected,
RewriteEngine on
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
now restart your server and check
Leave out the trailing slash in RewriteBase:
RewriteEngine On
RewriteBase /testing
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
$config['base_url'] should be http://localhost/testing/
$config['index_page'] should be blank.
Try this one in the .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
ErrorDocument 404 /mainpage
your config file is fine
Difference being the "?" after index.php
You may also want to try changing the value of $config[‘uri_protocol’] in ./application/config/config.php. Sometimes CodeIgniter gets it wrong. Changing it to PATH_INFOmight work.

Categories