I have successfully installed CI in the root directory many times, but now I have been forced to install CI in https://mydomain.com/mvc
There exists one controller "Login" with one action "index"
The .htaccess file looks like:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /mvc
RewriteRule ^(.*)$ index.php?/$1 [L]
In config/config.php
$config['base_url'] = 'https://mydomain.com/mvc/';
$config['index_page'] = '';
My routes look like:
$route['default_controller'] = "login";
$route['login'] = "login/index";
$route['404_override'] = '';
mod_rewrite is enabled
https://mydomain.com/mvc gives a 404
https://mydomain.com/mvc/login gives a 404
What do I miss?
What´s your hosting? if is hostgator you need add your user.
Try this
RewriteEngine On
RewriteBase /mvc
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mvc/index.php/$1 [L]
if your hosting is hostgator you need add you name user, for example
RewriteEngine On
RewriteBase /~<name_user>/%{HTTP_HOST} <or> <your folder>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /~<name_user>/%{HTTP_HOST} <or> <your folder>/index.php/$1 [L]
Try this
Set you default base url for subdirectory
$config['base_url'] = "http://www.example.com/subdir/"
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. So you have just replace it
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
This code run all sub directory. Hope this will help you!.
try this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mvc/index.php?/$1 [L]
I had the same issue and I could fix it by updating /etc/apache2/sites-enabled/000-default.conf file
try this.
mvc/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
mvc/application/config/config.php
$config['base_url'] = 'https://yourdomain.com/mvc/';
/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
....
<Directory /your/root/directory> # /var/www/html
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Related
I'm having issues with making codeigniter work on godaddy.
I tried various things but non seemed to work for me. Any help would be appreciated.
my htaccess file is like below:
RewriteEngine on
RewriteBase /code-igniter/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
and I already changed my config file:
$config['index_page'] = "index.php?";
$config['uri_protocol'] = 'REQUEST_URI';
Please help!!
<IfModule mod_rewrite.c>
RewriteEngine On
# If your page resides at
# http://www.example.com/code-igniter/
# then use
# RewriteBase /code-igniter/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
config/config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
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'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 am making application in codeigniter and now uploading to GoDaddy server but getting 404 error.
My code is like this
$config['index_page'] = "index.php?";
$config['uri_protocol'] = "QUERY_STRING";
.htaccess file is
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
I am getting value like
http://yourdomain.com/index.php?controller/action/etc
But i need
http://yourdomain.com/controller/action/etc
Please help.
try this
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
Try
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
Try this... it should work.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sgu_portal
RewriteCond $1 ^(application|system|private|logs)
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
RewriteCond $1 ^(index\.php|css|js|images|img|less|player-skin|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
input your folder CSS,js,images or else. If not your css not working.
RewriteRule ^(.*)$ - [PT,L]
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
and in CI Config
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
refer this answer
https://stackoverflow.com/a/16558169/1182195
make sure that your server configuration is set to
1 . Enabled mod rewrite
2 . Allow overriding htaccess in your apache
Thank you all for answer Thank you so much but correct answer is like this
code of htaccess file is like this
Options -Indexes
Options +FollowSymLinks
Options -MultiViews
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [NC,L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
I'm running my app in XAMPP with CodeIgniter. I have a .htaccess file that will not necessitate me anymore of including index.php in url but it won't work.
The content of my .htaccess file is
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|crossdomain\.xml|captcha|images|assets|archive|css|js|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
I already set the all the directories with AllowOverride to All. I've already enabled mod_rewrite too but still my links won't work. Instead of going to the specified URL, it will go the XAMPP homepage.
Also in my config file, it looks like this:
$config['base_url'] = '';
$config['index_page'] = '';
Then in view:
a href="/signup"
Am I doing it right? Please help.
Try
Options +FollowSymlinks
# Options +SymLinksIfOwnerMatch
RewriteEngine On
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|monitor\.php|resources|test_gui|img|css|js|favicon\.ico|(.*)\.(png|js|jpg|swf|css|gif|ico|jpeg|scss)$)
RewriteRule ^(.*)$ index.php/$1 [L]