How can I get my Laravel app to show on app.domain.com would this be in htaccess? If so how?
I'm not sure if i need to edit the paths.php in the bootstrap folder or can it be simpler by htaccess.
what you want is multi tenancy. your server needs to be configured with a wildcard subdomain (*.domain.com), so all your requests still get to your application. and when they hit your application, you decide what to do with the called subdomain.
here an example:
Route::group(array('domain' => '{subdomain}.'. Config::get('app.domain')), function() {
...
});
more about multi tenancy in the laravel docs.
on your localhost setup you can cheat that wildcard scenario by declaring your own sites in your hosts file like
127.0.0.1 localhost.dev
127.0.0.1 sub1.localhost.dev
127.0.0.1 sub2.localhost.dev
wildcards aren't supported for your hosts file
Related
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.
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?
Using cpanel I have upload into a server a laravel application. During the development I have used MAMP and it works fine.
When I upload the application into my host server, I only can see the first page:
http://myurl.com/appname/public/
When I try to navigate I always get this error:
Not Found
The requested URL /myurl.com/appname/public/account/sign-in was not found on this server.
What is the problem? Are there any special configuration for laravel applications?
Edit:
.htaccess file content:
Options -Indexes
SetEnv DEFAULT_PHP_VERSION 55
I tried to add RewriteBase /like this:
Options -Indexes
SetEnv DEFAULT_PHP_VERSION 55
RewriteBase /
But it didn't work either.
I'm using this host https://www.ecowebhosting.co.uk/?page=webhosting&tab=advanced
You didn't mention which web server you're using, but if it's apache, it looks like you need to either
Tell Apache to process .htaccess files (so it can see the rewrite rules that pass everything to index.php
Turn on the mod_rewrite module, which is the module that does the work of rewriting URLs
When you request a URL like
http://example.com/appname/public/account/sign-in
in a Laravel application, the rewrite rules turn that in
http://example.com/appname/public/index.php/account/sign-in
Behind the scenes. It looks like your server isn't setup to do this. Also, since you're serving Laravel out of a non root folder, you may need to set the RewriteBase. However, generally speaking, the ideal Laravel setup is one where the public folder is your web root. If possible, I'd configure your server so that's true as well.
I have been trying to get Laravel 4 subdomain routing to work for a couple of hours now and I just cannot seem to figure it out. I have a VPS and I'm fairly new to a lot of VPS concepts.
The domain in question is an account on the VPS - the main domain of the VPS is different. So, main domain is example.com and the account I am trying to get subdomain routing working on is foobar.com - a cPanel account on example.com
I put the following above the document root route on foobar.com's Routes file -
Route::group(array('domain' => '{account}.foobar.com'), function()
{
Route::get('/', function($account, $id)
{
echo $account;
});
});
I was expecting this to output the subdomain entered - for example something.foobar.com would echo something. Instead I get Error code: ERR_NAME_RESOLUTION_FAILED.
Since this is a cPanel account, I tried adding a subdomain in cPanel. This of course creates a directory of the same name as the subdomain in public_html, which is the doc root for that subdomain. When I navigate to the subdomain after adding it in cPanel, it says cannot list the directory.. blah blah.. basically it's an empty directory and the server will not show anything. If I attempt to delete the directory in public_html, I get a generic 500 error.
Clearly I'm missing something, the Laravel documentation either falls short or this type of server configuration requires something else. Help please! Thanks!
Woohoo! I got it working after a little more reading.
I had to log in as root to my VPS WHM control panel and add a wildcard A DNS entry (*) for the domain. Then I modified /etc/httpd.conf and modified the line ServerAlias to *.foobar.com foobar.com. Restarted httpd and viola!
This is awesome!