404 - File Not Found Controller or its method is not found: \App\Controllers\Ivy::codeignitor - .htaccess

I have a controller, named About:
<?php
namespace App\Controllers;
class About extends BaseController
{
public function __construct()
{
$this->data['site_title'] = "About Us";
}
public function index()
{
//return view('welcome_message');
return $this->_renderPage('About/index', $this->data);
}
}
the render_page fucntion is in the basecontroller as follows:
public function _renderPage($view, $data = [])
{
$data = array_merge($this->data, $data);
$data['_html_content'] = view('Home/' . $view, $data);
return view('Home/page', $data);
}
My folder structure is:
app
-Controllers
- About
- Home
- Contact
My view files are as follows:
Views
-Home
-Contact
- index.php
-About
- index.php
- ...
The way I reference about is
About
My .htaccess file has this line of code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php/$1 [L]
Why do I still get the error: 404 - File Not Found
Controller or its method is not found: \App\Controllers\Ivy::codeignitor when I enter url:
localhost:8080/myproject/about

try <?= base_url()?> instead <?= site_url()?>

Related

removing index.php in ci4 but nothing happen

I changed in App.php
public $indexPage = 'index.php';
To
public $indexPage = '';
and
public $uriProtocol = 'PATH_INFO';
and in .htaccess
require realpath(FCPATH . ..'app/Config/Paths.php') ?: FCPATH . ..'/app/Config/Paths.php';

How can I redirect 404 page to home page in codeigniter

I want to redirect all 404 error custom pages to home page in codeigniter if someone type something after proper url then user redirect to home page.
First, go to config -> routes, then scroll down until you found
$route['404_override'] = 'error404'; //by default it's '' (empty)
Second, you create a controller Error404.php
<?php
class Error404 extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
redirect('home'); //your controller (like Home.php or any controller that you want to call)
}
}
<?php
class Error extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index(){
$this->load->view('home');
}
}
?>
Edit error_404.php file (FilePath: application/views/errors/html/error_404.php)
Add your code before </body> tag like this:
<?php
header("Location: $yourhomepageurl");

ZipStream and Kohana 3.3

I'm trying to implement on the fly creating and streaming zip files in Kohana 3.3 using ZipStream (https://github.com/Grandt/PHPZip). I assumed that zip file would be streamed as soon as first image is added to zip, but it happens that download is stalled up until whole zip file is created and sent to user.
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Download extends Controller {
public function action_images()
{
require Kohana::find_file('vendor', 'ZipStream');
$zip = new ZipStream("images.zip");
foreach($images as $image)
{
$zip->addLargeFile($image);
}
$zip->finalize();
exit;
}
}
Apparently Kohana buffers output and that can be negated by adding this to download action.
while (ob_get_level() > 0) {
ob_end_clean();
}
Whole controller
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Download extends Controller {
public function action_images()
{
while (ob_get_level() > 0) {
ob_end_clean();
}
require Kohana::find_file('vendor', 'ZipStream');
$zip = new ZipStream("images.zip");
foreach($images as $image)
{
$zip->addLargeFile($image);
}
$zip->finalize();
exit;
}
}

Vanity URLs with IIS URL Rewrite

I feel like this should be easy, but I'm struggling. I'd like a user to be able to go to this url:
http://www.mysite.com/folder/some-id-text
and have URL Rewrite direct that request here:
http://www.mysite.com/folder/index.aspx?id=some-id-text
http://www.mysite.com/folder/some-id-text should be the only url the user ever sees.
in your project edit Global.asax file and add the code below.
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}
public static void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
routes.MapPageRoute("somename",
"folder/{text-id}",
"~/index.aspx");
}
then in your index.aspx you can find this variable as
string text_id = RouteData.Values["text-id"].ToString();
further ref http://code.msdn.microsoft.com/Easy-Steps-to-URL-2f792901

Symfony 1.4 https

I need to assign https to my symfony 1.4 project. The only thing I have to change is htaccess or I'll have to write something in filters etc?
I'm asking because I tried to do this with htaccess but with no results.
You can use filter to do it ,like this
class sfSecureFilter extends sfFilter
{
public function execute($filterChain)
{
$context = $this->getContext();
$request = $context->getRequest();
if (!$request->isSecure())
{
$secure_url = str_replace('http', 'https', $request->getUri());
return $context->getController()->redirect($secure_url);
}
else
{
$filterChain->execute();
}
}
}

Resources