I am sending a GET request to a route and I am getting back weird response when using
dd($request->all());
my route is
Route::get('{brand}/{type?}/{city?}', 'SearchController#index')->name('search');
my url is link/toyota?page=1 and the response back is
array:1 [▼
"/toyota" => null
]
I would like to mention that it is working on localhost using serve, but I am hosting this on cpanel
Edit : All query strings on my website does not work...
It was a problem with htaccess...
Cpanel changed my htaccess
if anyone comes here for the same reason, the default laravel htaccess is
<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>
Related
I'm writing a web application in laravel and have it almost working.
The only thing that is stopping me right now is the Rewrite Engine from apache ruining one particular route.
Route it should be: http://example.org/publicaties
Route it's
rewritten to: http://example.org/public
publicaties == publication but in dutch.
I'm using the following rewrite code as this is mostly the default for laravel if not completely:
DirectoryIndex index.php
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Any help would be awesome!
Thanks
Solved
Turns out laravel doesn't like similar names like 'publicaties' and 'publications' because after changing the url, the issue was gone. Thanks all!
I have created a website that was working fine, but now I am getting 404 not found error.
The live url is glucolight.co.uk
The main page is loading but all other pages show 404 not found.
I have .htaccess file in public folder with below content
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have tried putting same .htacces in root, in that case i get 500 general error.
Any solution please.
I have setup on host my 5.4 Laravel project.Everything used to work just fine but now when i try to access any page other then homepage i get 404 not found even when i want to access phpmyadmin panel (www.mywebsite.com/phpmyadmin).Is this a .htaccess config problem or something wrong with the server or domain ?
this is my .htaccess file content :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
You have to change the apache config to accept what is written in .htaccess file. This would help https://stackoverflow.com/questions/24784606/laravel-routes-not-working-apache-configuration-only-allows-for-public-index-ph
I have Laravel project works as an API, On my local machine it's working currectly but when I uploaded it on the server and send a request with Postman it doesn't send a post request, It's changed to GET request ! I read so many solutions and nothing worked for me.
https://imgur.com/p44fI1W
https://imgur.com/gdVLhXk
https://imgur.com/RKDpEom
My .htaccess file
<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>
Hy!
i'm using laravel 5.8 and when i put the wrong address in my url it give error
Trying to get property of non-object (View: C:\xampp\htdocs\cms\resources\views\post.blade.php)
url like
http://127.0.0.1:8000/lkfajds;
this is wrong url i put.
why this not back me to 404 page how can i do this
Want: i want to it redirect me to 404 page
Here htaccess
<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>
You need to use firstOrFail() on the model so it can show you the 404 page.