Not operating route in production

Asked

Viewed 699 times

-1

I’m having a problem, I recently deployed a 6 Airframe project in production.

I have the following route:

Route::get('/', function () {
    return view('welcome');
});
Route::resource('email', 'EmailController');

Locally access http://localhost/project/public/email and normally access the route, but when access in production, returns error 404.

My . htaccess is like this

   <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    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
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
  • In production you are trying to access also with public/email why it should be http://SeuendEndereço/email

  • I am... ip/project/email

  • And what appears?

  • From the 404, as if the route did not exist

  • If you have not configured your system to open without public, on the route you will have to also. http://SeuendEndereço/public/email

  • @Glenysmitchell but the route has, this is just the problem

  • What methods do you have in the controller?

  • Only Defalut, index, create, store, show, Edit, update, Destroy. but it doesn’t even go to the controller. not on the server, it works locally

  • As you are using Resource, check existing routes with php artisan route:list

  • I’ve looked over there, and it’s all right pointing the right way. as I said on the spot everything works, not something in the route or in the controller... I believe it is something in relation to the server configuration

  • Basically, I have done everything possible... I did a test, when doing the route Route::Resource('/', 'Emailcontroller'); it calls my controller correctly, when I leave it Route::Resource('email', 'Emailcontroller'); it is not called public/email, error 404

Show 6 more comments

1 answer

1

I think you’re having the same problem I had one day. This could be a matter of setting up the virtual host, or something like, where the address http://Your address/ will point to the public folder within your project (set the public folder as Documentroot).

I don’t know which operating system your project is running on, but if you don’t have the right virtual host, when you try to access the address http://Your address/project/email it will look for some file with the name 'email' inside the project root, even if it is with the configured route, thus causing error 404.

Here is an example of apache configuration running on a linux server

<VirtualHost *:80>
    DocumentRoot /var/www/html/projeto/public
    ServerName IpDoServidor

    <Directory /var/www/html/projeto/>
        AllowOverride All
    </Directory>
</VirtualHost>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.