All routes on my production website are working fine except for the /blog route which gives a 403 forbidden (nginx).
In web.php
Route::get('/blog', [BlogController::class, 'index'])->name('blog.index');
Route::get('/blog/{slug}', [BlogController::class, 'post'])->name('blog.post');
Route::get('/blog/preview/{slug}', [BlogController::class, 'postPreview'])->name('blog.post.preview');
I have deployed via Forge and Envoyer and didn't change anything in the server configs.
When using the default Laravel configuration the rewrite rule that rewrites all requests to index.php in order for the router to process them first checks if the request does not correspond to an existing file or folder. This is done usually to serve resources like e.g. js files directly without hitting Laravel. However this means if you have a folder that matches the same name as a route then the folder will take priority over the route.
In your case you have a folder called public/blog and nginx correctly returns a 403 because by default accessing directories to view their contents is forbidden.
Related
I need help in creating a redirect.
Our Current Setup:
We have a mobile app that accesses the API via https://ourwebsite.com/oldapi/mobiledata
We have moved to a new webserver and need the API path to stay the same.
On the new server, Wordpress lives at /var/www/html/webserver.com/public which resolves to https://ourwebsite.com and the Apache2 Document root
points to /var/www/html/webserver.com/public
Laravel has been installed on the webserver at: /var/www/html/webserver.com/laravel/ which is one folder below the Document root
A symbolic link has been created in /var/www/webserver.com/public/hq/ to point to /var/www/html/webserver.com/laravel/ so the Laravel App can be accessed by visiting: https://ourwebsite.com/hq/
Note: Another Symbolic link has been created for the laravel storage at /var/www/webserver.com/public/hq/storage which points to /var/www/html/webserver.com/laravel/storage/app/public
The new Laravel API endpoints are accessed at https://ourwebsite.com/hq/api/v1/
The Question
We need to preserve one particular endpoint1, and have its route be: https://ourwebsite.com/oldapi/mobiledata
Here is where I am confused. Since Laravel lives in https://ourwebsite.com/hq/ and Wordpress lives at https://ourwebsite.com, how can we set up the .htaccess so that the laravel route in /var/www/dux.city/laravel/config/api.php
I am guessing I need some fanciful .htaccess in the Wordpress route at /var/www/html/webserver.com/public
I am using custom configuration of domain names for my laravel project test as test.local . When I ran this project as test.local in google chrome , it shows laravel homepage. But, when I go to any other routes it shows internal server error.
Can anyone have any solution?
Just add index.php after the url, and then go to specific route
test.local/index.php/login
So in your routes file eg. web.php, do this if you need to, this adds on a domain limitation.
Route::group(['domain' => env('APP_URL', 'test.local')],function () {
//routes...
});
In you .env file, define the app url, you may use https if required
APP_URL=http://local.test
After all, I would strongly suggest you to check you nginx file to see if you are pointing the path to the right one. And also check if index.php is added into the index file property.
I have a Laravel 5.3 project with VUE.js. I'm using vue-router also.
As this app is a Single Page Application, i'm using AJAX from vue-resourse for all the data requests.
In my routes/web.php I have this:
Route::any( '/{any?}/{any2?}/{any3?}', 'AdminController#index' );
So every route should execute the index method of my AdminController, the routes are in charge of vue-router. This is working perfect.
The problem is in the api routes that manage all the ajax requests. I'm using the routes/api.php for this without any middleware.
In my local environment all of this is working fine but when I uploaded this to a Ubuntu 16 VPS on AWS all the api routes are giving me a 500 Error with this log:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Any ideas?
Here is the answer!
I donĀ“t know how (probably me drunk) I had the .htaccess in the proyect folder and not in the public folder...
I have install Laravel in my VPS, and it's working with the "public/index.php" in the url. I had tried lot more to remove this from url but all are failed, and I have to work with this. Currently I am working on the Sentinel authorization package. It's installed successfully but after login or when i click on the sentinal logo I always get redirected to the "http://myipaddress/tmb/" which is incorrect, so where I can set the home link so that it goes to the "http://myipaddress/tmb/public/index.php/". My laravel version is 5.1.20
The default config for the target URLs is the 'home' route. So you have to setup this route in your routes.php properly.
You can override the default routes in the config/sentinel.php file.
But anyway, it's very dangerous that anyone can access your whole application code directory. You should either forbid access to all resources which are not in /public directory or (much better) configure/ask your VPS to set the document root to your public directory!
I am in the Beta stage of a Laravel 5.0 project using BlueHost as the server. I have not finalised the domain so I am using a temporary address as follows:
IP Address/username
In a normal Laravel project the root URL is the domain name of the website and routing starts from there. However, in this environment, I have to adjust the route.php file. For instance, instead of the familiar
Route::get('/', 'WelcomeController#index');
I've had to do this:
Route::get('/username/', 'WelcomeController#index');
With the usual adjustment in the .htaccess to re-route everything to the public Laravel folder, I can use the temporary address and access the welcome page. However, when I start adding security with the Auth controller, the re-directs don't work. When accessing a secure URL, you are re-directed to IP Address/auth/login instead of IP Address/username/auth/login. In the .htaccess file in the public folder I've added:
RewriteBase /username/
with both slashes, but that doesn't help. Does anyone know how to set up a Laravel project with a secure area, secured by the Auth controller which has a URL that includes a second segment?