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?
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
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.
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.
Before I was in a shared hosting and had no problem installing and accessing (click next next), Laravel welcome page but I have moved to a bare metal VPS and I am having difficulties to get to the Laravel 5 welcome page. My host tells me to upload the framework to the htdocs directory, but that is exactly what I did and where the app et al are found.
This is the URL scenario.
My web VPS by default shows me its own index.html like this
/var/www/virtual/myweb.com/htdocs/index.html
and yes, I can correctly access that index through myweb.com
but, of course, all my views are in their Views folder, like this:
/var/www/virtual/myweb.com/htdocs/resources/views/welcome.blade.php
my routes page (as it is a freshly installed) naturally
Route::get('/', function() {
return view('welcome');
});
and the URL in my config/app.php file
'url' = >env('APP_URL', http://myweb.com');
If I do something like this in the URL browser box of course, I get to the file of Laravel 5 welcome page
http://www.myweb.com/resources/views/welcome.blade.php
but obviously I don't want to show such path
so, I would like to be able to write myweb.com and directly show my welcome.blade.php
Any ideas as to how?
You should point you web server (Apache) to a public directory of Laravel's project. For example:
DocumentRoot "/var/www/virtual/myweb.com/public/"
<Directory "/var/www/virtual/myweb.com/public/">
After rebooting web server normal URLs should work (if you'll set up correct settings).
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!