no input file specified error in codignator - codeigniter

Hi I am using CodeIgniter 1.7.3 framework in my project. I have given URL for a link like this
base_url/index.php/admin/featuredlink/flid/11
, and when I click on this link I am getting an error like this
no input file specified.
But when I change that link to base_url/index.php?admin/featuredlink/flid/11 it works fine.
In my local system this link [base_url/index.php/admin/featuredlink/flid/11 ] works fine.
Why is this link [base_url/index.php/admin/featuredlink/flid/11] not working?
How do I get this link to work? If any one knows, please reply.

Make sure first that you are changing your $config['base_url'] from your local development address to your remote development address. This is located in application/config/config.php.
Also make sure you're using the right URL Helper function for your needs. Here's what I mean:
The site_url() function/method will always include index.php in your URIs. Here's an example using the site name http://example.com as your website's domain.
<?php echo site_url('home') ?> will turn into http://example.com/index.php/home
While base_url() function/method will always exclude index.php unless you include it. Here's an example using the site name http://example.com as your website's domain.
<?php echo base_url('home') ?> will turn into http://example.com/home
and
<?php echo base_url('index.php/home') ?> will turn into http://example.com/index.php/home
Keep in mind that using these functions/methods are only effective AFTER you have properly modified your .htaccess file. Follow the link below to remove index.php from your URIs by modifying your .htaccess file.
http://codeigniter.com/user_guide/general/urls.html
Keep in mind too that this can vary from host to host in the way that it needs to be formatted, so follow up on that with your hosting service. Most usually have guides that show you how to configure this properly.
Here is the link that shows you a more in-depth difference between the site_url() and base_url() functions.
http://codeigniter.com/user_guide/helpers/url_helper.html
I hope this helps!

Related

Joomla 2.5 - How to fix 404 Not Found error after restoration using akeeba kickstart

After kickstarting a Joomla 2.5.22 on a new server in a sub-folder, the only page that works well is the home page, the rest give me (404 Not Found).
Tried many solutions found on the web even on Akeeba website here but still can't solve this issue.
I know that it's a path issue as if I add the sub-folder name in the address of the page that gives 404 error, the page displays properly.
Eg : www.testing.ca/mysub-folder/contact.html = Works well !!!
How do I dynamically add the sub-folder name for the entire site? or a best solution to solve this?
In your .htaccess file, replace the following:
# RewriteBase
With:
RewriteBase /mysub-folder/
Open your configuration.php file, and change:
$live_site = ''
to:
$live_site = 'http://www.[yourdomain].com';
Also in the configuration.php file, change the tmp and the log paths to the correct physical location.

Joomla 2.5 url shows two url with index.php and without

my url is http://www.clippingpathoutsource.com and it works fine but when I click to the logo of the page then the url shows http://www.clippingpathoutsource.com/index.php
Could anyone please help me?
it is difficult to identify the problem without looking at the code in the template file...
check the following:
1) In Template check index.php for below block of code
<div class="logoArea">
<a href="/index.php">
2) Instead of "/index.php" in the href attribute of the a tag put your domain name.

CodeIgniter always and only shows default controller or 404 page

I am asked to study about CodeIgniter but I haven't even heard about it before, so I'm trying to go through the textbook and official tutorial. But I can't even successfully display a Hellow World...I've tried to search the solution for a while but none of them helps.
Here's the specific problem. I'm building a CodeIgniter environment with MAMP, PHP version is 5.6.2 and CodeIgniter version is 2.2.0. But no matter what I do, the site can only show me the default controller or 404 page.
First of all here's "hello.php" in controller folder:
<?php
class Blog extends CI_Controller {
public function index()
{
echo 'Hello World!';
}
}
?>
I haven't set the mod_rewrite yet so I simply goes to this address:
localhost:8888/CodeIgniter/index.php/hello
And I only get a 404 page. So I tried to modify uri_protocol in config.php. I tried all of them, and QUERY_STRING and ORIG_PATH_INFO worked fine at first. I thought I succeeded. But I was wrong. I then setup a mod_rewrite with .htaccess file and I can only get a default controller (which is welcome page). I thought I must did something wrong in my .htaccess file so I tried to edit it but it doesn't work, so I tried to remove the file and go back to index.php/hello again, then I found that it can't work anymore, what I get is only a default welcome page.
I then tried to restart the server, modify index_page in config.php to 'index.php?', move CodeIgniter to root directory (I mean instead of localhost:8888/CodeIgniter/index.php, I removed CodeIgniter folder and just go to localhost:8888/index.php), totally remove the current CodeIgniter folder and download it again from official site, and of course tried other choices of uri_protocol. But nothing helps. What I get is still only default controller or a 404 page.
In summary, in config.php file, if I set
$config['index_page'] = 'index.php';
then
$config['uri_protocol'] = 'QUERY_STRING';
$config['uri_protocol'] = 'ORIG_PATH_INFO';
returns the default controller (even if I try to access a page which actually doesn't exist in controller folder), and other uri_protocols return 404 page.
Else, if I set
$config['index_page'] = 'index.php?';
then
$config['uri_protocol'] = 'PATH_INFO';
$config['uri_protocol'] = 'ORIG_PATH_INFO';
returns the default controller (also even if I try to access a page which doesn't exist in controller folder), and others return 404 page.
Also I thought it may be a problem with MAMP but even if I upload the whole site onto a VPS server (CentOS 6.5, php version 5.3.3) the totally same problem occurs.
Anybody has some idea?
First of all, to remove the index.php from your url, create a .htaccess file in your site root, and add the following code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
and then in your config/config.php file :
$config['base_url'] = '';
$config['index_page'] = '';
set the rest config parameters as usual.
Now, you are using the url localhost:8888/CodeIgniter/index.php/hello to access your application. This is wrong (unless you are routing the url). You have to load your controller which in turn loads the view for you. So, now use:
localhost:8888/CodeIgniter/blog
Again. One more thing. In the constructor of your Controller, you will have to call the parent constructor so that you can use loader class to load librariee, view, models whatever.
Now lastly, your best bet is to go through the documentation well. You have tried but not tried enough! Good Luck.
Umm well thanks for your help! A friend on Twitter told me that the class name was wrong, it should be the same as the php file (in this case, it should be class Hello extends CI_Controller)
After that, all things goes OK!
I was having this issue with CodeIgniter 1.7 when using it through the command line (CLI). I had to modify the _fetch_uri_string() function in the CI_URI class (system/libraries/URI.php) to see if $_SERVER['argv'][1] is set to find the URI being used. To find where your project's URI is present with your global $_SERVER variable, I would just do a var_dump($_SERVER); exit(); at the top of your index.php file.
Changes I made to the _fetch_uri_string() function highlighted:

Hide directory in source code

Actually my question is How is folder path hidden ? Firstly I am using Joomla.
I found a website 4 months ago, so i don't remember name of the website which is Joomla site. They hide their folder path.
Between to head> sth. head(tags). If you look at source code, you can see this part. And then this part include template name.
For example:
<link type="text/css" href="http://www.site.com/templates/template_name/css/style.css" rel="stylesheet"></link>
So we can learn to what the name of the template. But they hide this part. When i looked this part(http://www.site.com/templates/template_name/css), i can see only /style.css.
Do you have any idea?
You need two things to accomplish that.
A (system) plugin, that changes every template related URL to the 'official' format, eg.
$url = str_replace('/templates/template_name/css/', '/style/', $url;
An .htaccess redirect reverting the change.
RewriteRule ^style/(.*)$ templates/template_name/css/$1 [R=301,L]
If you want obscure template names, and a few modules and plugins from HTML source, the easy way is use a CSS and JS compressor like jbetolo or RokBooster.
But keep in mind that you will make a bit more hader to find your template name, but still possible via other ways. Like some images if they are not compressed in HTML.

How to link assets(images,stylesheet etc) in Views for CodeIgniter 2.1?

I am using CodeIgniter Version 2.1 & trying to link assets like images,stylesheets, javascript files etc in my views by using, header.php:
<link href="<?php base_url();?>css/style.css" rel="stylesheet" />
my controller code, calls the view:
<?php
class Main extends CI_Controller{
public function index() {
$this->load->view('header');
}
The view file from which I am trying to load the asset is located
../application/views/header.php.
the css file is loaded:
../application/views/css/style.css
this does not work. I get 404 - Page not found error.then, I tried moving css/style.css outside ../application directory in webroot. To my surpise, having assets in webroot(outsite ../application/views) seems to work nicely.
Now,
My Question is
Is having our assets directly in webroot, outsite ../application directory right approach? If YES/NO, then why?
If having assets directly in webroot is a good idea, than should I move ../application/views directory in webroot as well? How?
PS: I am new to CodeIgniter framework, so unaware of the best practices
If you see this, the section where .htaccess is used to remove index.php from the urls, that has a rewrite condition:
RewriteCond $1 !^(index\.php|images|robots\.txt)
In this line, images is a folder that will be ignored while mod-rewriting. So, you can replace it by assets, put all your directly linking files there, and happily use them.
RewriteCond $1 !^(index\.php|assets|robots\.txt)
EDIT: my bad, hadn't seen the date the question was asked. nevertheless, should be useful for someone.
It is best to put your assets in the webroot folder. When requesting assest from the server (depending on your setup), it will start from the root directory and work it's way down.
http://yoursite.com/application/views/css/mystyles.css
if it's in the root you only need to go from there
http://yoursite.com/css/mystyles.css
Although it might be worth putting them all inside a folder (/assets) to keep them contained, as well as the ability to write a more effective rewrite rule (if you are trying to remove the index.php from the url) to ignore the single folder instead of all the individual folders (/css, /js, etc)
As for the views folder, it's best if you leave it in the application folder as CodeIgniter has a built in loader that automatically checks /application/views for the view file when you use the code $this->load->view('myview')
Although there are way to move the views folder, if you are new to CI it's probably best to leave it there for now.
For linking css you can do something like:
echo link_tag('css/mystyles.css');
Check this for ref: http://codeigniter.com/user_guide/helpers/html_helper.html

Resources