Upload CodeIgniter project to cpanel - codeigniter

I have worked on that the whole day, but I couldn't find why I always get the CI 404 Page not found. The project works very well in localhost. What could be the problem?
This is my .htaccess
RewriteEngine on
RewriteCond $1 !^(index.php|css|js|jq|uploads|robots.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
I suspect the default controller can't be found.
What more do you think I should show you?
I will be grateful for your answers.
PD: I use CI 2.1.2

If you've set up everything right, then try changing your last line to: RewriteRule ^(.*)$ /index.php/?$1 [L]
EDIT
Since it's not working when you disable .htaccess and use index.php, you need to check your config.php for things like base_url, index_page, uri_protocol, etc... and routes.php and make sure the default controller is not capitalized (read more about the naming conventions, but I wrote you the general idea in the comments).

Related

Migrating a CodeIgniter site to a different domain and moving the whole thing down one level in directory

I am working on a site, which is built with CodeIgniter.
I have never used the framework before...I've learnt a little bit in the last couple days but really cannot solve my problem.
I have downloaded the site and I want to upload it to my own domain so not to make changes to the live site before testing.
the original site is example.com.
I want to upload it to mysites.com/examplesite (this will be the base - I use this domain for all my clients' test sites).
I have moved all the files and the database is in place.
I have found the database configuration file and have successfully edited it.
I am having trouble getting the site to work, I think it must be because of the site now being down a directory level.
I have edited $config['base_url'] so that it is correct...I am pretty sure it is correct because I can now reach the homepage where I couldn't before editing that variable. But, i can only reach the homepage - when I click on a link to another page, I get 500 error Internal server error.
Does anyone have a quick fix for me?
Thanks!
Keep this code on your project's root .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /examplesite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

How to setup a 301 redirect using mod_rewrite

I must admit, mod_rewrites are still a bit of black magic for me and I try to stay well away from them unless I really, really need to us them, now I do!
I've just migrated my site to become a multi lingual site and in doing so I've made the following change to the structure.
oldwebsite.net/somefile.php >> newwebsite.com/xx/somefile.php
oldwebsite.net/somefolder/somefile.php >> newwebsite.com/xx/somefolder/somefile.php
Now, I know how to do individual 301 redirects, but I got tons of pages and the new structure hasn't changed the page name so I would like to avoid setting up hundreds of individual 301 redirects, help!!
Thanks,
Mikael
You can put this code in your oldwebsite htaccess (which has to be in root folder)
RewriteEngine On
RewriteCond %{HTTP_HOST} oldwebsite\.net$ [NC]
RewriteRule ^(.*)$ http://newwebsite.com/xx/$1 [R=301,L]

Joomla not finding index.php after

I had turned Use URL rewriting to ON
Added some code in to the ht access file and this never worked.
I then turned off url rewriting and removed the code and now when I try to go to the website I am getting a 404 error.
I can still access /administration
the website is www2.daxtra.com
the page it should find is http://www2.daxtra.com/index.php/home
Does anyone have any ideas what has happened?
This was the code I added:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Thanks
Right, I've done a small test.
To get what you want, you need to following:
htaccess.txt (you don't need a .htaccess file)
Search Engine Friendly URLs set to On
Use URL rewriting set to Off
You finally need to ensure that your Homepage menu items it set to a specific component such as an article or something else, not an Alias
This will ensure that you get example.com/index.php/home
Hope this helps

Codeigniter HMVC without 'index.php'

I implemented the wiredesignz HVMC functionality in CI 2.1.7.
The only problem, is that, unlike the tutorial I followed(http://somethingstatic.com/setting-hmvc-codeigniter-2-1/), I have to add 'index.php' in my url:
how it should be according to the tutorial:
http://localhost/site/hmvc
What I actually have to call:
http://localhost/site/index.php/hmvc
How can I configure CI so the 'index.php' is not needed?
You need not to do anything extra. this link will help you to get this thing done. Just normal procedure. I done multiple times with the same one.
Hope this helps you.
//user following code in your .htaccess file to remove index.php from url.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]

mod_rewrite understanding sub-directories whilst passing $_GET value server issue?

This may well be a server config issue; or simply a blindly obvious reason I'm missing...
Pre mod_rewrite URL:
www.example.com/subfolder/index.php?userName=x
The devised mod_rewrite:
RewriteEngine on
RewriteRule ^subfolder/[^/]([\w]*)$ /subfolder/index.php?userName=$1 [L]
It is my understanding that the above should allow navigation to: www.example.com/subfolder/x. However this causes a 404 error.
Rewrites without the sub-folder work fine; it is only when adding the subfoler to the mix things fall to put.
Your advice is much appreciated.
Try this one instead (works OK for me):
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/subfolder/index\.php$
RewriteRule ^subfolder/([^/]+)$ /subfolder/index.php?userName=$1 [L]
NOTE:
This rule is to be placed in .htaccess. If placed in server config / virtual host context, some small tweaking will be required.

Resources