GoDaddy + CodeIgniter + subdomain - .htaccess

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]

Related

How to solve sub-directory issue on hosting server

I hosted a website to a sub-directory in a hosting server.
But it is redirected to the main domain when I try to navigate to the sub-url of the website.
So, I added the .htaccess file to solve this problem.
The .htaccess file is the following.
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]
But I am getting the problem continuously.
Please let me know how I can solve it.
You can write the following contents to your .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-directory/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sub-directory/index.html [L]
</IfModule>

Htaccess file not working on phpmyadmin.ovh.net

I use codeigniter for my website buliding, after following the process to remove index.php file, everything work properly on localhost but when i host my site on phpmyadmin.ovh.net it's not working anymore, i can't reach any link. Can somebody help me ?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Codeigniter page not found

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

.htaccess and subdomains

Hey Folks am seemingly having problems with .htaccess files.
The problem:
I have a wp install in the root directory. In a sub-directory (not a domain) there is Modx. When I enter the url to the root/modx the url is treated like a wp link and it goes back to the homepage. In other words I think the .htaccess is overriding.
The main directory (wp) has this .ht file (after digging around for a solution)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^office/.*$ - [PT]
# BEGIN WordPress
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
This is the one in the subdirectory
RewriteEngine On
RewriteBase /cms
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
well you could add the following rule to your wp .htaccess just before the RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} !modx

Using htaccess to remove codeigniter index.php in a subdirectory

I'm trying to remove the index.php from my CI urls, but having followed the instructions it doesn't seem to be working.
I have a codeigniter installation running in a subdirectory. There is a default controller set in the routes config called main, and another controller called 'create'. The default runs fine, but going to /create returns a 324 error saying No Data Received. My htaccess looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
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>
This should be enough:
<IfModule mod_rewrite.c>
RewriteEngine On
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
This is what I use. My CodeIgniter also runs in a subdir.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
.htaccess add:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Go into application/config/config.php and clear the index page config value:
// Old
$config['index_page'] = "index.php";
// New
$config['index_page'] = "";
Solved My problem hope others too... :)
Sometimes you need to enable it the rewrite module, run "apache2 enable module rewrite":
sudo a2enmod rewrite
You need to restart the webserver to apply the changes:
sudo service apache2 restart
Then folow Sofia's answer.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
for ubuntu

Resources