My project is build using Angular and Springboot. In environemnt.prod.ts file I have backend url.
I am not sure what does it mean to make url ralative so that it should use same server url?
enviroment.prod.ts file
production:true,
url:'http://localhost:8080/api/amazon/steven'
The relative URL does not use the full web address and only contains the location following the domain. It assumes that the link you add is on the same site and is part of the same root domain.
Update environment.prod.ts file
production:true,
url:'/api/amazon/steven'
Related
I have a website running on an apache2 server and serving out of a user directory. The URL looks like this: http://example.com/~user1
This serves up files on my server located at /home/user1. The problem that I am facing is that a lot of the asset URLs throughout the site are put into the HTML as relative paths like this: <img src="/images/example.png" alt="" />
This is attempting to load the image from http://example.com/images/example.png, but I actually want it to serve from http://example.com/~user1/images/example.png.
How can I accomplish this?
/images/example.png
This is a root-relative, not a relative URL-path.
This is attempting to load the image from http://example.com/images/example.png, but I actually want it to serve from http://example.com/~user1/images/example.png.
This is a client-side/browser URL resolution issue. There are no "switches" on the server that can be applied to change this behaviour, without changing the actual URLs.
This is an inherent problem with using Apache per-user web directories.
Your options are:
Don't use Apache per-user web directories. ie. Remove /~<user1>/ from the URL.
Or,
Use relative URL-paths to your assets. eg. images/example.png (no slash prefix). So the browser correctly resolves this as /~user1/images/example.png instead (when accessed from the document root at least). But this creates additional problems if you are rewriting the URL of your pages at different path depths or using common templates in your pages etc.
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
I am using MVC routing in asp.net Web forms and I want to remove the folder/directory name appended in the URL. Locally this works fine but I have the following address now appearing on Godaddy shared hosting.
www.mywebsite.com/my-folder/contact
but I want like this
www.mywebsite.com/contact
I have tried web.config techniques but no success that's why I am asking is there any way to redirect this using Global.asax.
I am using WebAPI 2 with Attribute routing in my project. I deployed my project under a virtual directory in IIS. I need to remove virtual Directory name from the URL.
Now my URL is api.mydomain.com/virtualdirectory/{controllerName}/{Version}
In my Route Prefix I am passing controllerName/Version.
I need to change the URL to
api.mydomain.com/{controllerName}/{Version}
Please help me how can i achieve this using attribute routing.
The question is will a request like api.mydomain.com/{controllerName}/{Version} hit your action?...route templates(with conventional or attribute routing) are always relative to the base path of your application and if the base path of the application includes the virtual directory, then the request urls would need to have this information to hit the actions...one option i can think of is to host your application directly under the website...
I want to prevent users access for my "~/Content/..." folder I wrote it as follow in "Global.asax.cs" and put this line of code at the top of every other routes
routes.IgnoreRoute("Content/{*pathInfo}");
but it does not work. in fact user can see every files in content folder by type the URL in browser.
am I missing something?
How did you figure out that it does not work? Give example.
You may have put it last in the Routing table. So try to move it up so that it gets added to the routing table first. The route collection is an ordered list of routes.
Also try this : Routes.IgnoreRoute("Content/");, but your version of ignore is also correct and it should work.
Lastly, I do not know what you mean when you say the user can see all the contents of the Content folder : Isn't that the point? User must be able to download files from the folder, and we usually just need MVC to ignore the requests from coming into the framework, and so that IIS can directly serve those files.
or did you mean Directory browsing is enabled, and you want to disable that : In that case go to IIS manager, and select your website and look for the Directory browsing option and disable it as shown here.
Your problem cannot be solved by routing constraints. There are 3 significant steps in processing request:
IIS got request.
IIS watch at filesystem and search for direct correspondence to file
If IIS didn't found any file - it gives request to ASP.NET MVC for processing.
So, you need to configure folder security to forbidden direct access to files, but allow access to application, as here.
But I don't recommend to secure folder, that should be shared. I don't believe that your site shouldn't have images to display :) If you have some secured content, you need to create another folder.