How to mask outbound URL in ASP.NET MVC? - asp.net

I'm trying to redirect and mask all users from a page at my ASP.NET website to another website not using ASP.NET. ie, from www.site.com/site2 to www.site2.com. I want the url to be masked, so that users see www.site.com/site2 in their url rather than www.site2.com, and for subpages like site.com/site2/home to also work. My website is hosted on Microsoft Azure, and I would ideally like to redirect to a completely different page, but could also redirect to another Azure page.
However, I've been getting a bit confused with terminology. What methods can I use to go about this, and is there a specific search term I should be using? There are a lot of resources that discuss doing the opposite (masking part of your website as another site), but fewer masking an outward site as part of your site.
So far, I've found a couple of possible methods - Virtual Directories, and URL Rewrite.
For Virtual Directories, I found this useful blogpost: http://blogs.msdn.com/b/kaushal/archive/2014/04/19/microsoft-azure-web-sites-deploying-wordpress-to-a-virtual-directory-within-the-azure-web-site.aspx
But it doesn't quite work and I'm finding it difficult to find any more resources about Virtual Directories.
I also found URL Rewrite, which looks pretty cool: Mask URL to subdomain using IIS
However, they also mention that URL rewrite only works on the same website, which is not the case here.
Will either of these work to mask site2.com as site.com/site2?

I was not able to do exactly what I wanted to - simply redirect traffic from site.com/site2 to site2.com (and let users see site.com/site2 in the url). URL Rewrite does not do this, but it does do the opposite (map server content at site.com/site2 to user sees site2.com).
Virtual directories are close enough though. I'm actually storing the content at site.com/site2, so users see that as the URL. If I want users to alternately see site2.com if they go there, I can use URL Rewrite.
The first blog post I linked (http://blogs.msdn.com/b/kaushal/archive/2014/04/19/microsoft-azure-web-sites-deploying-wordpress-to-a-virtual-directory-within-the-azure-web-site.aspx) actually is spot on with how to set up Virtual Directories.
One of the problems for me following that post was the Site name and destination URL of the publish settings.
Basically the extension from Azure (outlined in red) matches the URL from publish settings, while the site\wwwroot\wordpress from Azure (green) matches the Site name from publish settings.

Related

Website is showing another website on non-existent website page

This is a peculiar one.
I work for an agency, and we develop WordPress and JAM Stack sites for our clients.
I have been contacted by the IT team for one of the clients (an NGO), and they flagged something that I have not seen before.
NOTE: I am going to be using example.org as the website, to protect the identity of the client.
Basically, we developed a WordPress site for them, which works great and all, but as it turn outs there is a page on the website which points to a totally different website
The example page is as follows
example.org/news/points-to-different-website/
The news page doesn't exist in anywhere on WordPress system, and neither does it exist as a custom post type.
And another thing, I noticed is when I removed the / at the end of the URL, it shows the custom 404 page developed for the website
example.org/news/points-to-different-website
But as soon as you add the /, it shows a totally different website.
I have checked all the Apache configuration files related to the site, and it is just the normal setup for any WordPress site.
So, I am wondering what could be causing this, and how can one prevent it?
That's a strange issue. Does example.org/news/points-to-different-website/ actually redirect to another full URL, i.e. differentwebsite.com, or is the different site actually at example.org/news/points-to-different-website/?
Try
emptying the trash for both pages and posts, as there could be a conflicting slug that is causing a redirect.
Reset permalinks.
Using PHPMyAdmin, search the database for the URL points-to-different-website and see if there is malware or some kind of a redirect, an iFrame, etc.
This can sometimes happen if the server hostname is not set up correctly.
What can happen is website on the server will show in place of a non-existent site or page from another website on the same server.
If you are using a reseller hosting/shared hosting, then the site could be from another account on the server, the site could also be from another server, for example:
There are 2 servers with the hostnames serverone.myserver.com and servertwo.myserver.com... A site on serverone might show in place of a site or page on servertwo.

Is it possible to hide URL trail?

Problem is simple, I have a web site www.mydomain.com which have other links to other pages (in the same site) like www.mydomain.com/some/directory/some_page.asp. I would like to know if it's possible to hide the second part and show only the www.mydomain.com.
I'm using DotNetNuke, IIS web server.
Is it possible to do this with the url_rewrite module?
Do you want all the URLs to show up in the browser as just the domain? the only way to do this would be to use an Iframe, which is a TERRIBLE idea. It means that no one can copy and paste your URLs to send to their friends, and if they just get the URL anyway because they know how to use a browser users will see the full path anyway.
The url_rewrite module won't do what you're after either. It can rewrite one URL to another, e.g. instead of www.mydomain.com/mypage.asp you could have www.mydomain.com/mypage. But you couldn't map ALL of your pages to just the root domain (think about it, how would it know which of your pages to serve up for that URL).
This is something people used to ask for back in the 90's. It was a bad idea then, and it's an even worse idea now.

wordpress: domain mapping and site URL display

i am a wordpress newbie and have not much experience with their settings. Basically, i have recently set up a domain mapping for an existing wordpress site that i took over and that i had to move to another host, so domain mapping seemed to be an easy option to point the old URL to the new host. I have set up the domain mapping to point to the new site from:
http://www.myOldExample.com
to the new one:
http://www.myNewWebsite.com/foldername
So far the content migration worked in wordpress. The problem is that when i type in the old URL in the browser, it redirects the old page and shows the new site for the main home section as expected, but for all the subsequent links such as About, Contact, Products etc. it shows the new URL with the subfolder path, whereas i would like them to display the old URL as the base URL, so i am not sure if i need to change anything on the domain mapping site, or does this need to be done on the wordpress side? Does wordpress offer something like a base URL rewrite? I could only find in the general settings the Site URL and Wordpress URL, but i am not sure if changing those values to point to the old URL would break the site.
Many thanks for any ideas.
I think, this is url problem. When you are migrating wordpress site from one server to another server or same server but different folder, so its create url problem like http: //theoldserver to, for example, http: //thenewserver.com is problematic. So download file from this site and put this file, where blog files placed on server. Then do step, which define on this url.
This is very handy tool
Search and Replace for WordPress Databases Script" tool that's very handy (make sure to read the instructions and have a backup of the db before using it).

SSL and relative URLs in site links and redirections

I have been working on a website in beta phase for some time now, and am finally about to launch it. There are several links, anchor tags, with relative URLs throughout the site that link to the admin and cart sections of the website, and now they have to be SSL secured.
Also, same question for relative URLs in Response.Redirect("~/../..");
When a user is browsing over http, is there anyway to redirect them to a page with https connection using a relative URL? It seems like poor practice to code absolute URLs for links and redirections for the purpose of SSL. If the domain name changes, I have to rewrite them all. Plus, if I want them to work on my localhost, I would have to change them every time I upload to server. There must be some solution.
Switching Between HTTP and HTTPS Automatically is a very good code to use for the implementation of switching logic fast and easy - and not change your existing code.
Similar: Preparing my ASP.NET / MVC site to use SSL?
These helper methods by Rick Strahl will help you
http://www.west-wind.com/weblog/posts/2007/Sep/18/ResolveUrl-without-Page
Pay special attention to ResolveServerUrl.
Depending on what version of IIS you are running, you could always offload this functionality to the webserver. Check out the URL Rewrite module here.

How to manage sub-domains on WinHost with IIS7 URL Rewrite 2.0?

I'm trying out WinHost and I'm running into some issues with sub-domains. On WinHost, you can have multiple sub-domains per hosting account, but each sub-domain points to the root website. E.g. you can have www.example.com, sub1.example.com, and sub2.example.com but all of them display the content at http://www.example.com/.
Other Hosts allow you to point sub-domains to a sub folder in your website. This would allow you to point sub1.example.com to /sub1, sub2.example.com to /sub2 and www.example.com to /.
WinHost recommends using an asp/aspx page to redirect http://sub1.example.com to http://sub1.example.com/sub1, which points to /sub1. While that would work, I'd like to not have the subdomain in the url twice.
So I tried using IIS7 URL Rewrite to point http://sub1.example.com to /sub1. Ben Powell describes this in detail on his blog. This is great, except Request.ApplicationPath is now /sub1/path/to/current/page.aspx, which breaks ASP.Net Themes (and probably other stuff too).
What can I do to fix the ApplicationPath? Is there a better way to accomplish this?
I tried my luck on serverfault. No helpful answers there either, but I did post my solution:
I couldn't figure out how to fix the
application path, so now I'm simply
using the URL Rewrite Module to
redirect (not rewrite) from
http://sub.example.com/abc to
http://sub.example.com/sub/abc. It's
not ideal, but it works. See my blog
post for the details.
https://serverfault.com/questions/134125/how-to-manage-sub-domains-on-winhost-with-iis7-url-rewrite-2-0/135533#135533
Altaf's article explained the resolution by removing the ~ sign. Look at the point 7 there.
Winhost.com – How to REALLY run multiple sites under one account
see below url
https://benpowell.org/winhost-com-how-to-really-run-multiple-sites-under-one-account/?unapproved=31073&moderation-hash=8d58e661f6d4dafcd93335a0a837b193#comment-31073

Resources