I have big problem trying to remove index.php from url's
i have searched lots if forums (this also), but no help for my situation.
so i have config.php file
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
my .htaccess file in public_html folder near index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /public_html/
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>
and in WAMP apache (ver.: 2.4.9) i have rewrite_module ON (and it's working)
and my httpd.conf AllowOverride set to All
so when i am going to mydomain.com/controller/action - I get 404
but when i go to mydomain.com/index.php/controller/action - everything is OK..
i have tried lots of .htaccess examples... and so on.. nothing helps..
Use this htacess and then go to config.php and remove index.php
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Related
I have uploaded my website on 000webhost server in vegshop folder, my link is "http://sp16bcs034.000webhostapp.com/vegshop/", however there is error 404 page not found
and my .htaccess file code is:
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]
Try the following
Open config.php and do following replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
In some cases the default setting for uri_protocol does not work properly. Just replace
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note: .htaccess code vary depending on hosting server. In some hosting server need to use an extra ? in the last line of above code. The following line will be replaced with last line in applicable case:
// Replace last .htaccess line with this line
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Try this htaccess file, you have uploaded code in the subfolder.
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^$ /vegshop/index.php [L]
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /vegshop/index.php/$1 [L,QSA]
Or sometimes time you have to replace the last line in above code with this as per server
RewriteRule ^(.*)$ /vegshop/index.php?/$1 [L,QSA]
Place below .htaccess file in vegshop folder
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /vegshop
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<ifmodule !mod_rewrite.c>
ErrorDocument 404 /index.php
</ifmodule>
In application/config/config.php set as below
$config['base_url'] = 'http://sp16bcs034.000webhostapp.com/vegshop/';
I have hosted a website of codeigniter framework by using godaddy server.
The website is working nicely. And home page of admin panel is also working, but after first, the sub pages are giving page not found error, when I am trying to log in.
I think its a url directions error.
From Comment
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options -Indexes
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>
The below settings works for me:
First change this valiables in /application/config/config.php
$config['base_url'] = 'http://example.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Then change in .htaccess file
RewriteEngine on
Options -Indexes
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
I upload the codeigniter in the subfolder and in the root I have a wordpress webstie. I change the config base url with the name of subfolder name like this
$config['base_url'] = 'http://xxxxxxxxxxxx.com/onlinebooks/';
But after this still getting 404 for any controller I call on url
Can Anybody help me regarding this?
Try this
Create a .HtaAccess in root folder and paste this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
404, maybe you have modified your code to remove the index.php on the url, this would be the correct .htaccess.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /onlinebooks/
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
RewriteCond $1 !^(index\.php|images|stylesheets|javascript)
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Hi all im trying to hide the index.php from the url, well something like that:
i want : mydomain.com/index.php/mycontroler
to be like : mydomain.com/mycontroler
here is my .htaccess
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
And here is my conf.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
the problem is that it was working good in the local but not in the server
here is the disposition of my files
- bin
- etc
- mail
- public_ftp
- public_html
-- application
-- assets
-- system
-- .htaccess
-- index.php
Help guys
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';
$config['index_page'] = '';
htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
if still getting troubles try changing :
$config['uri_protocol'] = 'REQUEST_URI';
to
$config['uri_protocol'] = 'AUTO';
or somenthing different more (in the config.php you'll find all the options available to try for the uri_protocol param)
Here is .htaccess stuff,
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /
# Restrict your site to only one domain
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
#prevent access to htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
#disable directory browsing
Options All -Indexes
IndexIgnore *
And in config.php
Set base URL like 'http://www.example.com/'
Set $config[‘index_page’] to an empty
string Set $config['uri_protocol'] = 'REQUEST_URI'
all my .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|static)
RewriteRule ^(.*)$ /index.php/$1 [L]
and you should make sure that property AllowOverride is set correct, eg:AllowOverride ALL in your httpd.conf Directory segment
Make the below changes in the root .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
It worked for me.
I am newbie with Codeigniter 1.7.2. I want to skip index.php and method name of Site URL. But I don't know how to skip them.
My site url looks like -
http://localhost/mysadagi_voicetongues/index.php/deal_bazaar/PrivilegeDealsbazaar
So I want skip index.php and PrivilegeDealsbazaar from url.
Please give solution to fix this issue.
Thanks
Use latest version on CI 2.1.3
You can use .htaccess to hide index.php from URL. You can use following .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#AddHandler application/x-httpd-php5 .php
RewriteBase /projectforlder/
RewriteCond %{REQUEST_URI} ^system.*
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>
You can not access your controller without specifying it in URL.
you can do this in 3 steps:
1) Create .htacess file in parallel to application holder
and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/ /* this will be your prj name. Change it as per your directory structure*/
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.
I forget to tell. open your config file: application/config/config.php and change this line
$config['index_page'] = “index.php”
To
$config['index_page'] = “”
Create a .htaccess file in the root of your app so
system
application
assets
.htaccess
To delete the index.php from your url use this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
It's not a very good idea to hide the controller name because you will get a lot of problems when routing and linking to other functions.
Hope it helps!