Generate route url from subdomain to the main domain - laravel

I have a multi-tenant app. So let's say I have test.app.com and app.com. I can successfully navigate from app.com to test.app.com but I am unable to the opposite.
I tried wrapping the routes of my app.com inside a Route::domain() but that only gives me a 404 error instead of actually redirecting it to the url
EDIT: Just to make sure, I want to redirect using a relative path (with the route() method).

Related

Get an image stored in a Codeigniter project

Basically I have 2 frontend projects and one of these uses some assets that are stored in the other one.
In my java frontend (let's name it this way) I have to use www.codeigniterFront.com/img/example.png to get an image stored in my Codeigniter frontend, the problem is that it throws 404 error because that's not a valid route in my codeigniter router. So is there a way to ignore the router for all the /img/* routes or somethin I can do?

ngnix - rewrite url based on path

I have my next.js app working on http://testdomain.amazonaws.com:443/abc.
Using ngnix configuration, I would like to have https://anotherdomain.com/abc to render my app at http://testdomain.amazonaws.com:443/abc without changing the url in the address bar and also it should take the routes from the next.js app keeping the https://anotherdomain.com.
That is, if user clicks on other links and navigates to other routes like
http://testdomain.amazonaws.com:443/abc/pqr/1 it should become https://anotherdomain.com/abc/pqr/1 in the url.
Can anyone help me understand if we can write a rewrite rule to achieve this in ngnix?

Laravel subdomain route problame

I am working on a subdomain system on laravel.
suppose my main domain name is: test.test
and my subdomain name is: subdomain.test.test
Now, the problem is, when I use the main domain route in sub-domain blade file like:
Profile
then, it should generate links like test.test/profile
but, it's generating links with subdomain like: subdomain.test.test/profile
Now, How can I solve this problame?
An alternative would be to use relative path instead of absolute using route() helper third parameter.
Profile
I recommend you to use Spatie Multitenancy, when i do route('home'), he return back the url with the actual domain.

Laravel one specific route gives 403 (nginx)

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.

Firebase hosting seo friendly url

I'm using firebase hosting for my blog
I use this
mydomain.com/?postid=how_to_etc
Method to get my post data
Is there any way to use SEO friendly url like,
mydomain.com/how_to_etc
So that this link should not redirect to 404 error page
This kind of behavior requires rewrites configured with a single page app to interpret the URL path for its own router. this does depend on your current setup to determine the final work required.
alternatively, if you are using simple HTML; you can look at window.location properties and split the path with split.("/") to determine the path . See:
https://developer.mozilla.org/en-US/docs/Web/API/Location

Resources