2

I installed laravel 5.7 on XAMPP. Now, when I want to publish a post. I am getting the bellow error. Please help. Thanks in advance.

Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404
localhost
Apache/2.4.34 (Win32) OpenSSL/1.1.0i PHP/7.2.9

create.blade.php

<form method = "POST" action = "/posts">

    {{ csrf_field()}}

    <div class="form-group">
        <label for="title">Title:</label>
        <input type=""text" class="form-control" id="title"name = "title">
    </div>

    <div class="form-group">
        <label for="body">Body:</label>
        <textarea id = "body" name = "body" class = "form-control"></textarea>
    </div> 

    <button type="submit" class="btn btn-primary">Publish</button>

</form>
Lakhwinder Singh
  • 5,536
  • 5
  • 27
  • 52
Shamima Saleem
  • 143
  • 1
  • 1
  • 9
  • The from url is `http://localhost/blog/public/posts/create`, but once I fill up the from and click on publish button, it takes me to `http://localhost/posts` url. – Shamima Saleem Oct 16 '18 at 03:28
  • Do you have a `.env` file in the project directory? If not create one then add `APP_DEBUG=true` this will turn on debugging, which will give you a meaningful error message. – Lex Oct 16 '18 at 03:39
  • Hi Lex, yes,I have it – Shamima Saleem Oct 16 '18 at 03:42

3 Answers3

0

I think you are using "laravelcollective/html", If yes kindly try to set up the virtual host to the public path of the project and try again

OR

instead to laravelcollective Form tag, use simple form tag and give action="http://localhost/blog/public/posts/create"

Also, request you to please put all form tag code here, so can debug easily. Hope your issue will be solved.

Amol Rokade
  • 145
  • 1
  • 11
0

Make your project inside htdocs folder

You're got an error because the object really doesn't exist in your htdocs directory.

htdocs (or www) is the directory that the Apache web server looks for files to serve on your domain by default.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
  • Hi Udhav, I created the project inside htdocs directory during installation. – Shamima Saleem Oct 16 '18 at 06:09
  • check .htaccess in your public directory? – Udhav Sarvaiya Oct 16 '18 at 06:12
  • In my .htaccess, I have this `# Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301]` – Shamima Saleem Oct 16 '18 at 06:36
  • Copy all code and paste your .htaccess file Options -MultiViews RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] – Udhav Sarvaiya Oct 16 '18 at 06:39
  • I replaced .htaccess code with this code but didn't work at all. Should I replace only # Redirect Trailing Slashes If Not A Folder... part with your code? – Shamima Saleem Oct 16 '18 at 06:52
  • This is my current .htaccess file. Options -MultiViews RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] – Shamima Saleem Oct 16 '18 at 07:01
  • @ShamimaSaleem No problem in your `.htaccess` file – Udhav Sarvaiya Oct 16 '18 at 07:08
0

I solved the issue by <form method = "POST" action="{{ route('posts') }}>

My Route here Route::post('/posts', 'PostsController@store');

Shamima Saleem
  • 143
  • 1
  • 1
  • 9