ASP.NET Url Rewrite Subdomain Wordpress II7 Web.Config - asp.net

I have a server that host a variety of asp.net sites on a IIS7 server.
A few of those sites have wordpress blogs in a folder called blog (which is obviously written in PHP). Due to security issues, we need to move those wordpress blogs to a linux server.
So instead of http://www.domainname.com/blog we now have http://blog.domainname.com/ which has the blog url.
The only problem is, due to SEO reasons, we need the blog to be on the same domain as the main site (which is written in ASP.NET).
My question is, is there a way to do a url rewrite so that if someone types in a wordpress link, similar to this:
http://www.domainname.com/blog/index.php/archives/category/mycategory
Can I use a web config URL rewrite to have the above typed in URL actually point to
http://blog.domainname.com/index.php/archives/category/banking
I can't do any sort of redirect. It has to be a rewrite, I've tried righting one myself but have been unable to. The subdomain is the part of the rewrite I can't get past.
Has anyone tried to do this before?
Is there some better way I go about this if not.
Keep in mind the blog and the asp.net site cannot be on the same server due to security reasons, but they must keep the same domain name.

You can't just do a rewrite as the URL you want to rewrite to is on another domain / website. Rewrites only work on the same website.
You have to setup IIS as a reverse proxy server with the ARR module. In combination with the URL rewrite module you will be able to invisibly forward all requests for http://www.domainname.com/blog/* to http://blog.domainname.com/*.
Also note that you will have to setup outbound rewriting in order to change back the URL's that are generated by Wordpress (from http://blog.domainname.com/* back to http://www.domainname.com/blog/*).
See for an example this tutorial: Reverse Proxy with URL Rewrite v2 and Application Request Routing.

Related

How to turn WP https site to http (from secured to non-secured)

I have a simple WP blog that doesn't need https.
My host was offering a free SSL certificate so I took that up.
It's only after that I read that turning a site to https is like having a brand new site and therefore starting SEO all over again.
I've recently moved host and had to use the backups I made to move the content across. I've found out all the internal links on the site are https, probably because the site was secured at the time of making the backup. Unfortunately the browser says my https pages are not secured despite an SSL certificate that seems installed.
Rather than resolving that, I think I will benefit more by turning my site back to http. All my backlinks over the years point to http. So how do I convert all internal links that point to https pages back to http?
All the resources I find online are to turn http to https.
Database
You need to change the site and home urls in the database table wp_options to the url without https.
Links
Then use a plugin to change the media links and anything using your https url to the http url, I recommend Velvet Blues here wordpress.org/plugins/velvet-blues-update-urls
Redirection
You also need to redirect all your https urls to the http one, you can use this plugin wordpress.org/plugins/redirection. As Google and other search engines have indexed https for your site.
Permalinks
You can also try update your permalinks in General > Permalinks and just resave it.

How to mask outbound URL in ASP.NET MVC?

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.

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.

Extract URL's from a website?

I would like to migrate a site, but the new URL's are completely different from the old URL's. I do not want to break my old sites links that are out there on the web. Is there a way to extract all the links from a site so I can generate a redirect table (I will probably put the redirects on the web server level)? The old is on ASP.NET with SQL server 2008 by the way. Am open to crawling the site or mining the SQL database, but need some help or advice.
You could use IIS Seo Optimalization Toolkit for that. http://www.iis.net/download/seotoolkit
With that tool you can spider the entire website. Then when the report finishes, go to Content -> Host summary and double click the host of the website. There you have a complete list of all spedered URL's.
And ofcourse, when you have these url's, you can make URL rewrite of routing mechanisms available to 301 to the right content on the new website.
The best way is to actually put a 301 redirect to notify all engines that your URL's have permanently moved Search for 301 in this http response code documentation for more info on 301. That is if I am understanding your problem (that you want links from other sites and searches and whatnot to realize that your site moved?).
It doesn't sound like you're running Apache. However, Apache has an available module called mod_rewrite. There may be a similar module for other web servers.
mod_rewrite allows you to do exactly what you are describing.
Perhaps with litle js magic if works for you

Redirect subdomain to subfolder of another subdomain

What I want to do is take traffic that is going to shop.mywebsite.com and redirect or rewrite (I'm not sure of the terminology) the domain to be www.mywebsite.com/shop. Both shop.* and www.* are separate web applications (nopCommerce and Umbraco respectively) that don't seem to cooperate when I've tried to nest them. Both applications are in a Server 2008 R2/IIS 7.5 environment.
I've searched around stackoverflow and what I've found is a lot of answers to mapping the other direction (ie subfolder to a subdomain) but that's not what I'm looking for as far as I understand the problem.
The end goal is to combine the SEO reputation of the shop subdomain into the www subdomain. I readily admit that I might have this all backwards and am willing to try any suggestions I'm offered.
Thanks.
I think you are looking for URL rewriting.
URL rewriting is the process of
intercepting an incoming Web request
and redirecting the request to a
different resource. When performing
URL rewriting, typically the URL being
requested is checked and, based on its
value, the request is redirected to a
different URL
EDIT:
You may also want to check URL Rewrite Extension from microsoft, it will fix common SEO problems that your site might have.

Resources