.htaccess file does not working on godaddy server - php

Can someone tell me why this code would work on my local server but not on godaddy server?
I get the following error on godaddy...
I have creating one codeigniter project and host on godaddy server but .htaccess file does not working
my problem is "https://www.tripbrip.com/index.php/home/app_view" this same url come in my url side but i want to remove index.php in this link
my directory structure is this:
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ index.php/?$1 [NC,L]
my config file:
$config['base_url'] = "https://".$_SERVER['HTTP_HOST'].'/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
This file run in my localhost but not working on server.
I have use many code but still problem remain same .
If I browse to http://example.com/bootstrap.php I get a 404 resource not available at /

Maybe u can try put this on your .htaccess
<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php/$1 [PT,L]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And for your config file. maybe u can just empty it.
$config['base_url'] = '';
If still error, you can try this
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('#/+$#', '', dirname($_SERVER['SCRIPT_NAME'])).'/';

The following setting works fine for me.
RewriteEngine on -MultiViews
Options All -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
in application => config => config.php
$config['index_page'] = ''; // should be blank
instead of
$config['index_page'] = 'index.php';

Related

Remove index.php from url in codeigniter using htaccess

I tried to remove index.php from my url in codeigniter i tried by creating with .htaccess file but it does not works.
RewriteEngine on
RewriteBase /
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
I tried by using this code and also these are mu bse and site url.I not have much knowledge that how to use htaccess properly.Any help is appreciable.
$config['base_url'] = 'http://localhost/xxxx/';
$config['site_url'] = 'http://localhost/xxxx/index.php';
Open config.php and do following replaces
From:
$config['index_page'] = "index.php";
To:
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
Add in .htaccess file
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Hope this will help you :
Options +FollowSymlinks -Indexes
RewriteEngine on
DirectoryIndex index.php
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and also set your config.php:
$config['index_page'] = '';
$config['base_url'] = 'http://localhost/foldername/';
for more : https://www.codeigniter.com/user_guide/general/urls.html
Try the below code to remove index.php from url, Make an htaccess file in the root folder and paste the below code in it.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
For remove index.php in the url you need to change the configuration.
Change the following in your config.php file
$config['index_page'] = "index.php";
TO
$config['index_page'] = "";
This will remove index.php from url.
If it helps anyone here, this problem drove me crazy and the solution for me was removing the capital letters from the project folder (it was originally localhost/working/CourseIgnite/).
so after many attempts at the problem I changed site to localhost/working/courseignite/
Then using the solutions that everyone posts worked. Mod rewrite on, change base url and index in the config, and used the below in the htaccess.
Just hope this helps as it was driving me bonkers.
RewriteEngine on
RewriteBase /working/courseignite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Then in application/config
$config['index_page'] = "index.php";
TO
$config['index_page'] = "";
and also in application/config
$config['base_url'] = "yourlocalhostip/working/courseignite/";

Removing index.php in Codeigniter 3 apache2 server

I am working on Code Igniter in Kali Linux, I have configured .htaccess file as mentioned in Documentation and configured file correctly but its not working without index.php
a2enmod rewrite
I have also enabled rewrite mode and restarted apache. Here is my .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
in config.php
$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';
create .htaccess file with the following at your project's loctation
(for eg: /var/www/html/yourproject create .htaccess inside 'yourproject' folder )
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
add the below to your virtual host configuration file
<Directory "/var/www/html/yourproject">
Options All
AllowOverride All
Allow from all
</Directorey>
then restart apache
Follow this steps to remove index.php from url
1)Remove "index.php" from config.php file
$config['index_page'] = "";
2) Your .htaccess file should be:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
3)Some cases you also have to change this in config file
//find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"
Simply use this in your .htaccess file
<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 /index.php
</IfModule>

Removing index.php from CodeIgniter URL

I'm struggling with removing the 'index.php' part of my CodeIgniter URL.
I'm using CodeIgniter version 3.1.2. I've followed all steps on other questions about this:
Changed $config['index_page'] = 'index.php' to $config['index_page'] = ''
Changed $config['uri_protocol'] = 'AUTO' to $config['uri_protocol'] = 'REQUEST_URI'
Added a .htaccess file in the root folder of my project with 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]
However when I try to access my site, I get the following error code.
Not Found
The requested URL /Toneel/Site/index was not found on this server.
The rewrite module is turned on in my Apache Server.
Can anyone help me out with this issue?
This setting worked for me.
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
To allow overriding htaccess in Apache Configuration you have to edit and change /apache2.conf file to
AllowOverride All
And restart server.
Try this code in .htaacess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
Try this in your .htaccess file
RewriteEngine On
RewriteBase /yourfolderhere/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
In my case, it works with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project-name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
** Important, this should be in an .htaccess file in the root of your project.
In config should be like this:
$config['base_url'] = 'http://your-url-here/';
$config['index_page'] = '';

Index.php remove from url is not working in CI 3

I have tried a lot to remove index.php from the url .
Its not working at all.
In config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Then put this below code in .htaccess of my project root.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
I have tried ,its throwing page not found errors only.
Any suggestion ??
Thank you
Your base URL is not the base domain name, so modify your .htaccess file and add the following:
RewriteBase /cloud
This should fix your issues.
You need to change config.php and .htaccess file.
Changes in application/config/config.php
$config['index_page'] = ""; // And Remove index.php
Changes in .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Make Sure
Your .htaccess must under cloud directory.
Rewrite module must be enabled in Apache.
try this ,
Changes in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Make sure your RewriteEngine is on in apache conf file if not then follow this link
How to enable mod_rewrite for Apache 2.2

CodeIgniter .htaccess remove index.php on Server

I know there's a lot of questions and answers here but I'm really confused and I couldn't fix my problem yet. Please help!
I can easily access my controller via this url:
http://www.example.com/new/index.php/welcome
but I can't get it via this URL:
http://www.example.com/new/welcome
I'm configuring my CodeIgniter site in a subdirectory "new" and on my server, my directory structure is:
/
htdocs
new
/ (this is empty), htdocs(here is my directory named as "new" and new(this is the exact folder where I've my codeIgniter files.
I'm confused here about "/" and "htdocs", I think this is the thing which I'm not able to handle because my domain example.com is pointing to htdocs i.e if I put index.php in htdocs, example.com will load index.php.
my .htaccess file in "new" directory is :
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
in config/config.php:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
I've tried $config['uri_protocol'] for "Auto", "REQUEST_URI" and "QUERY_STRING" etc.
With this configuration I'm able to remove index.php in my local host but I can't fix it on server. Please help!! Thanks in advance.
this one worked for me
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
make sure to remove index.php from appliation/config/config.php
$config['index_page'] = '';
put this code in .htaccess file inside new directory
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And dont forget to remove whitespace from:
$config['index_page'] = ' ';
Try with this code in .htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Try either changing the
$config['uri_protocol'] = 'PATH_INFO';`
or changing the rewrite rule to use the query string instead:
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1
Then setting the protocol to query string:
$config['uri_protocol'] = 'QUERY_STRING';`
If you say that it's working on localhost, then it might be a server problem. Check if the server mod_rewrite is on by writing phpinfo(); somewhere in your view code. If it's not on and you don't have permissions, contact your host admin.
This code works for me:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
And the config.php
$config['index_page'] = '';
Try adding ? after index.php in htaccess,
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Categories