i've website built with CODEIGNITER working perfect on my local server but when i uploaded it on live it give me error 404 and after updating .htaccess with following code now its giving me 500 error
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /home/index.php?$1 [L]
any solutions...
This is an .htaccess rule so specify your RewriteBase as the manual says (you've read this of course). That's
RewriteBase /
for a DOCROOT/.htaccess and if your Codeigniter catachall script, index.php is in DOCROOT as well then the rule should be:
RewriteRule ^(.*)$ index.php/$1 [L]
this works for me
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
in config.php
$config['index_page'] = '';
and
$config['uri_protocol'] = 'AUTO';
hope it help
Related
I have created one project in codeiginiter
That was worked in local server without index.php (localhost/sample)
But when i up-ed into online server(cpanel linux) the default controller only worked , other next page URLs are not worked.. (https://sample/nextpage)
if i give index.php means worked (https://sample/index.php/nextpage)
i want to remove index.php , please help me..
my config.php
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';
my route.php file
$route['default_controller'] = "pages/home";
$route['pages/profile'] = "pages/profile";
$route['creators'] = "pages/userList";
$route[$username] = "pages/userList/userview/$1";
$route['translate_uri_dashes'] = FALSE;
$route['404_override'] = '';
my .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Options All -Indexes
Thanks in Advance,
Shruthi.
Try to change the code of your .htaccess file with the following
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Change .htaccess file
RewriteEngine On
RewriteBase /name of project folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
try this
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|img|css|public|tmp|download|javascript|rte|document|xajax_js|robots\.txt)
Please contact your hosting provider and check mod_rewrite module is enable or not?
Basically I want to remove index.php in my url.
I think my .htaccess is not working on Hostgator and I've already searched my problem on these .htaccess, codeigniter and hostgator.
This is my folder structure in hostgator
/cgi-bin /httpdocs
|---/application
|---/system
|---.htaccess
|---index.php
My .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
My config.php
$config['base_url'] = 'www.example.com'; // this is only an example because our website is confidential
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Edit: Sorry for being idiot. I contacted the Hostgator after I posted this question and try the answers below. They say that I'm
running on Windows server not Apache server so my .htaccess will
not work so I need to convert it to web.config. Sorry for those
wasted time to answer this question. Thank you
Edit: I mark #Deep Parekh's answer as correct as #David said that it worked properly
Generally i use this htaccess on Hostgator:
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Make sure you changed your config.php file:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
.htaccess will look :
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
</IfModule>
In codeiginator config:
$config['uri_protocol'] = 'AUTO';
If htaccess is not working then
Configure Apache mod_rewrite
a2enmod rewrite
Add the following code to /etc/apache2/sites-available/default
AllowOverride All
In config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
In .htacess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule
I think its possible to use the htaccess.
http://support.hostgator.com/articles/specialized-help/technical/apache-htaccess/how-to-edit-your-htaccess-file
Maybe try these htaccess. It works at my local project.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(index\.php|\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./index.php [L]
This is works for me:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I'm attempting to remove index.php using the CodeIgniter framework (hosted with GoDaddy - Linux), which is currently installed to: example.com/ci
I've already declared the base_url in application/config/config.php as http://example.com/ci/.
The following is my latest test input for .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
Keep in mind that the domain CI is installed under is not my hosting root. The actual path for the CI folder would be: root/mydomain/ci
After spending the better part of the day today trying a plethora of "solutions", I'm beginning to wonder if this is possible to do with GoDaddy at all, or perhaps my situation is somehow unique.
Any advice would be greatly appreciated!
EDIT: The closest I've come to fixing this issue is using the following .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /clone/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^index.php/(.*)$ [L]
</IfModule>
.. while setting my base_url to mydomain.com/clone/ (using http:// of course) and removing index.php from index_page. Navigating to mydomain.com/clone works fine but navigating to the two pages that are part of the software results in a 404 page.
An answer to your comment, you need to add a rewrite condition to access the sites/ directory. CodeIgniter is looking for sites in the controllers folder.
RewriteCond $1 !^(index\.php|sites)
You can also add the names of your resource folders like images/video etc.
Change this
In your config.php
$config['base_url'] = '';
$config['index_page'] = '';
then in .htaccess
RewriteEngine on
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
or else you can use your .htaccess too
EDIT 01
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I've just installed codeigniter, so if I type:
http://mysuperwebpage.comyr.com/projects/thebookshelf/index.php/welcome
It displays everythin as it should.
But I want to get rid of this index.php in the url, so you can access welcome controller without need to type index.php before /welcome:
http://mysuperwebpage.comyr.com/projects/thebookshelf/welcome
So i was following all needed steps which I found in same questions here on stack. What I've tried:
config.php:
$config['base_url'] = 'http://mysuperwebpage.comyr.com/projects/thebookshelf/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess file that is located in the root folder: http://mysuperwebpage.comyr.com/projects/thebookshelf/.htaccess
Attempt #1 (not working)
.htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Attempt #2 (not working)
.htaccess:
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Attempt #3 (not working)
.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
What am i missing or doing wrong? First time using .htaccess.
Make sure you .htaccess file is under the root folder and not the application folder.
This is something you may not pay attention to.
According to CodeIgniter docs, this is one way to do it:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Well, i've found this information in the FAQ of the host:
On this page
So what i had to do is add this lines before everything:
RewriteBase /projects/thebookshelf/
So now it's looking like this:
RewriteBase /projects/thebookshelf/
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I hope this will be helpful to people who use use virtual user home directory paths, as was in my case.
This works for me
For your .htaccess file (locate it in root folder)
RewriteEngine on
RewriteBase /yourProjectName
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
config.php
$config['base_url'] = "";
$config['index_page'] = "index.php";
$config['uri_protocol'] = "AUTO";
Inside public_html dir open .htaccess and update below script
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I'm using codeigniter. I removed index.php on localhost successfully but it's not working on distant server.
When I try to call: http://website.com/user/login it gives me [File not found]. But it works when i type: http://website.com/index.php/user/login
I put all files on www folder and this is my .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [PT,L]
Could anyone help me please?
Thanks.
This is the .htaccess I use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Have you checked your .htaccess file is correct on the remote server and that it is being read?
This Works for me:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And in your config.php:
$config['uri_protocol'] = 'AUTO';
This will remove index.php from both localhost and distant server.