Unable to run the app on hosted server - codeigniter

I have just installed Ci framework and tried on my local some basics according to the tutorial.
http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html
On local machine, everything was OK and page was displayed.
Than I upload project to the server (I am using wedos web hosting where I already have som web which is working correctly) but this is not working for the application which I copied it here. When I type the URL I got 404 error.
On my webhosting service I have www folder where i put my index.html file. Than when i type www.mydomain.eu I get this index.html file. Than I have subfolder www/folder/index.html Than when i type www.mydomain.eu/folder i get this page so it is ok.
Than i have www/folder2/here i unzip CodeIgniter framework and when i type www.mydomain.eu/folder2, 404 Page Not Found appears. The error is not general error from browser but generated from the CI framework.
I have created my own controler in application/controllers/mycontroller.php
<?php
class Mycontroller extends CI_Controller {
public function view($page = ‘enter_form’)
{
$data[‘title’] = ucfirst($page); // Capitalize the first letter
$this->load->view(‘templates/header’, $data);
$this->load->view(‘pages/’.$page, $data);
$this->load->view(‘templates/footer’, $data);
}
}
And I have following structure of views:
views/pages/enter_form.php
views/templates/header.php and footer.php
And the following settings:
1) $config[‘base_url’] = ‘’; but I have tried ‘http://mydomain.eu/’ and ‘http://mydomain.eu/www/’ or ‘http://mydomain.eu/www/folder2/’
2) $route[‘default_controller’] = ‘mycontroller/view’;
$route[’(:any)’] = ‘mycontroller/view/$1’;
Thank you for any help

Sounds to me like there is either a configuration issue or a rewrite issue going on. Do you have a .htaccess file in your CI root folder where your index.php file lives? Seeing that you are depending on the CI to pick up any uri and reroute it to a specific route, this might be the issue. I've ran into issues with this before on different hosts. Make sure mod rewrite is enabled and make sure your .htaccess is something similar to this:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|uploads)
RewriteRule ^(.*)$ /index.php/$1 [L]

Ok, so it seems like the typo somewhere, because when I used the default CI welcome pages, it works. So I will try to find the typo myself and i will see...

Related

Laravel - Catch specific public folder route

Sorry if this sounds so basic.
I've encoutered a scenario where I need to add certain checks when user access certain file in public folder.
With default setting, you can access specific file in public directory directly by typing its url in the browser: Sorry this is misleading.
You can access an image with:
localhost/img/banner.jpg
But I can't catch it with:
Route::get('/img/banner.jpg', function(){
//checks goes here
});
How it should be done?
You should create controller for serve images(files) and disallow direct access if you need control. On example:
Route::get('/file/{name}', function ($name) {
// Your check and return file with correct response headers
}
Or best way to create controller for that.
https://laravel.com/docs/5.6/filesystem . Check laravel Docs to see how manage multiple file storages.
I just found another way without using filesystem.
In .htaccess inside public folder, add these:
RewriteCond \banner.jpg$ !-d
RewriteRule ^ index.php [L]
Which will let laravel handle the route then I can catch it with:
Route::get('/img/banner.jpg', function(){
//checks goes here
});

Default controller (under modules) not loading under HMVC, CodeIgniter, throws 404 err

Just migrated my CI from localhost to live. Everything works fine on localhost with same settings.
Here're the folder/file structure and contents of routes.php
-application
--controllers
---Home.php
--modules
---specs
----controllers
-----Specs.php
----models
----views
$route['default_controller'] = 'Specs/index';
//$route['default_controller'] = 'Home/index';
$route['404_override'] = 'Errors/show_404';
$route['translate_uri_dashes'] = FALSE;
Both Specs and Home controllers have index method. When I load the home page url with Specs/index as default controller, I get 404 error. But if I change the default controller to Home/index, it loads just fine. Strange. Everything else works just fine on whole site. Can't figure out.
The website is live but I'm not sure if providing url is allowed, so I'm including spaces in it. It's unspecs dott comm. Admin/Mods may please remove if url isn't allowed.
Thanks for reading.
I think you are doing mistake in routing, for HMVC it should be like that -
$route['default_controller'] = '<folder name>/<controller name>/<function name>';
$route['default_controller'] = 'specs/Specs/index';
Please follow this, hope it will work fine.
Try this https://stackoverflow.com/questions/6529026/codeigniter... But better use standart folder for default controller /application/controllers

How to call sitemap.xml in codeigniter application

i have added sitemap.xml file to my codeigniter project.
And i call it on my localhost like that : http://localhost/demo/sitemap.xml
it runs without any issue.
But when i run it on live server http://example.com/demo/sitemap.xml
it says 404 page not found.
What is issue ?
you need to add below things in your config/routes.php file
$route['sitemap\.xml'] = 'demo/sitemap'; // your navigation path i.e. your controller_name/function_name

visible vanilla dashboard to only one ip-address (admin)

http://fidm.in/vanilla/
I want to restrict these two urls
[1]: http://fidm.in/vanilla/dashboard/settings , http://fidm.in/vanilla/settings outside my ip-address.
I have tried through .htacess but no success.
If .htaccess not work.you try php custom code $_SERVER['REMOTE_ADDR'].
Go to applications/dashboard/views/settings folder
and use custom coding in index.php
if($_SERVER['REMOTE_ADDR'] != '00.00.00.00'){
header('Location: http://www.rediect-domain.com/');
exit;
}

Symfony2 and mod_rewrite URLs not working

I have this pattern configured in my routing.yml:
/{customer}/{site}/content/{id}.{format}
Now I want to omit the /{customer}/{site} part and rewrite it with a rewrite rule.
Symfony already has a .htaccess with a rewrite rule. I modified it to
RewriteRule ^(.*)$ app_dev.php/foo/bar/$1 [QSA,L]
But when I point my Browser to http://localhost/content/42.html I get this Exception:
No route found for "GET /content/42.html"
I fiddled around a bit and found out, why this problem occurs: Symfony uses the _SERVER['REQUEST_URI'] variable to parse the request, but when you use mod_rewrite, the URL in this var is not the expected /foo/bar/content/42.html but content/42.html.
I could replace the app_dev.php with my own one and overwrite the REQUEST_URI but I don't want to hack Symfony.
Edit:
Removing the /{customer}/{site} part from the routing config is no solution because I'm working on a multi customer/multi site application and I want to hide those parts via an URL, so that I can point my browser to www.my-fancy-site.com and the apache rewrites this URL to /foo/bar/content/42.html.
good that you asked:
Do sth like:
app/config/routing.yml:
blog:
pattern: /{customer}/{site}/content/{id}.{format}
defaults: { _controller: TestBundle:Blog:view ,customer:foo, site:bar }
And don't touch the rewrite rules in .htaccess or app_dev.php at all
EDIT: For your updated question you will need this, too:
app/config/routing.yml:
blog:
pattern: /
defaults: { _controller: TestBundle:Blog:view, customer:foo, site:bar, id:4 }
But this way the url keeps http://host/. I would use a welcome controller and then simply redirect from that to the other route... One Redirect should be ok.
To be more precise: You will need two routes and a controller just for redirecting to yours.
Please RTFM here:
http://symfony.com/doc/2.0/book/controller.html#route-parameters-controller-arguments
and here:
http://symfony.com/doc/2.0/book/routing.html

Resources