Welcome Guest, Not a member yet? Register   Sign In
Redirect Help
#1
Photo 
(This post was last modified: 06-29-2020, 07:03 PM by zpupster.)

[attachment=1811][attachment=1811]Hello support,

I am new to CodeIgniter. I am following this tutorial. https://www.youtube.com/watch?v=TC_9EuMTPN4&t=1090s

I am on Xampp On W10 and i have a form with this URL:

(see attachment)
[/url]
Code:
http://localhost:8888/codei4/public/blog/create
 which exists here: C:\xampp\htdocs\codei4

The Problem is with the redirect:

Code:
return redirect()->to('/');

I have tried searching all i am getting is this is a bug in CodeIgniter4----

Is there a Solution  ???????


When I press the submit(create) button, ti takes me to this URL:
Code:
http://localhost:8888/blog/create/
[url=http://localhost:8888/blog/create/]  with a ObJect Not Found!  Error 404!



Config/App:
Code:
public $baseURL = 'http://localhost:8888/codei4/public';
public $indexPage = '';
public $uriProtocol = 'REQUEST_URI';
.htaccess in public folder:
Code:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Routes look like this:
Code:
$routes->get('/', 'Pages::index');
$routes->get('blog/create', 'Blog::create');
$routes->get('(:any)', 'Pages::showme/$1');

I have tried hard coding(codei4/public in front of every instance of blog/create in my code.

I need help.

If you need further Info --Let me know.

thank you

Attached Files Thumbnail(s)
   
Reply
#2

So, is your problem is when you submit your form it got you 404?
And did your submitted form data got in into your database?

Maybe try change the route into:
PHP Code:
$routes->get('/''Pages::index');
$routes->post('blog/create''Blog::create');
$routes->get('(:any)''Pages::showme/$1'); 
Reply
#3

Are you using the .htaccess that is shipped with CI4 in the public directory?
The RewriteBase directive needs to be changed if you are running in a subfolder (as is indicated in the comment of that file).
Reply
#4

(This post was last modified: 07-03-2020, 09:49 AM by inumaru.)

Oh right, as tgix say.
I set my base_url to be dynamic so i don't need to change my .htaccess file.

app/Config/Constants.php
PHP Code:
$protocol= (isset($_SERVER['HTTPS']) ? "https://" "http://").$_SERVER['HTTP_HOST'];
$protocol.= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
defined('BASE') || define('BASE',$protocol); 

app/Config/App.php
PHP Code:
public $baseURL    BASE
Reply




Theme © iAndrew 2016 - Forum software by © MyBB