Add www prefix to URL - asp.net

I have an ASP.Net MVC 3 Website hosted on a shared Windows hosting package. I wish for my site to automatically add a 'www' prefix to all my site pages when the user does not type it in, ie, mytestpage.com redirects to www.mytestpage.com.
I have browsed extensively through Stackoverflow and other Internet sites to find a solution to this, but to no avail. The solutions given are to either configure IIS itself, however, I do not have access to IIS as I am using a shared hosting package.
Others have said to add the prefix via the web config file IIS7 URL Rewrite - Add "www" prefix however this seems only to work with IIS 7.
Is there any other way I can achieve this?
Your help is greatly appreciated.
Thanks.

On my solutions I do a check on Application Start whether the request has www or not. If not, I redirect to www.
And all my links are relative, of course.

Related

All my Kentico live sites 404 and the previews do as well

I created a site in Kentico 12 and using the live viewer was working fine. Now its started 404ing every time I try to go to the site either by the URL: localhost:8080/Kentico12_[sitename] or by viewing the site through the live site feature. I a new site and it does the same thing. Additionally, page preview 404s as well. I have tried changing domain alias' and URL patterns but it doesn't seem to work. If anyone has a solution or some useful documentation to point mee toward that would be appreciated.
I can get into the back end of the site no problem by going to http:localhost8080:/Kentico12_Admin
I can reinstall Kentico 12 if needed but would rather avoid that.
Reinstalling is not the answer. Make sure you have the site properly setup in IIS first. A simple setup is to set the root of the site in IIS to the root of your MVC site. Then under that main site, create a virtual application and set that to the root of the CMS directory and call that virtual application "cms".
Then navigate to localhost/cms and you should be directed to the Kentico login page. Once you've logged into the Admin interface, update your site's domains. The Site domain name should be localhost/cms. The Presentation URL should be http://localhost.
If after you've made those changes and you're still getting 404's we'll have to look into other possible issues maybe in your web.config.

Redirect loop to old URL on aspx site

I inherited a site that worked on the domain.
Hosted on a plesk server from GoDaddy.
I placed a new site on oldguard.org which is hosted on ionos (formerly 1and1) and is working fine as is...you can see it at https://oldguard.org.
I wanted to take the old site that use to be on oldguard.org (current plesk site) which I can't not get to load at all, and place it on a new domain http://demotoga.com.
I have checked the servers with the domains and everything seems to be pointing in the right directions. However, when you go to demotoga.com, you get redirected to oldguard.org which is hosting the new site. For some reason, the old site (plesk location files on Godaddy servers) will not load on demotoga.com no matter what I do. It just keeps redirecting to Oldguard.org.
I believe the problem lies in the web config file for the hosting files that are for the old site which use to live on oldguard.org but cannot locate why the site continues to redirect. Shouldn't the site appear on demotoga.com if everything matches up?
I've looked around and around and cannot find where it points to the oldguard.org URL. What other Information is needed to solve this issue? Happy to provide any coding or give additional information just not sure what is needed to solve this issue.
Full web config code can be found here:
https://www.oldguard.org/wp-content/uploads/2018/12/oldguard-oldwebconfig.pdf

IIS 6.0: How to add a site/app to a site taken over by WordPress?

In my new job, I "inherited" a website that is completely implemented by WordPress. That is, every URL that starts with that http://www.myjobdomain.com is somehow redirected/generated by WordPress and, if a page does not exist in that location, it provided a 404.
I am now trying to add a "side site" to that domain, that is a web app (or a few html pages) that are outside that WordPress-based site.
Is there a way to accomplish that in IIS 6.0?
I know that in Apache I can play with .htaccess and redirect/rewrite rules to accomplish what I want. But in IIS 6.0 I could not find any way to do this.
If such a way exists, how would I go about to this? Any instruction or guidelines would be sincerely appreciated.
P.S. In my IIS Manager, I could not find any tabs alluded to by this answer.
To accomplish what you want, all you need is to right-click your site in IIS Manager and select Add Application....
Unless your site is already configured to relay all control to WP. In such case, you may want to look into Microsoft's URL Rewrite module/extension.

Steps to redirect url of website to wordpress site in sub folder keep same url with IIS server

I have searched this thoroughly, but can not fine the solution for IIS 7.
My client has an active website hosted on an IIS 7 server. I have created an WordPress website in a sub-folder of that directory.
Example: clientSite.com ~ clientSite.com/_dev/
I am looking for the steps to point the entire site to _dev folder, and be fully functional but not have it show the redirect. In other words, the _dev/ never shows in the site path, even though all pages and posts of the site are in the clientSite.com/_dev/ path. Essentially, I need to strip the _dev from ever being seen.
I have seen this done with Apache servers, but have not found anything on IIS server redirect cloaking.
The purpose for doing this is to have the site switched to the dev site until I can change the files and database to the original site url, then turn off the redirect.
You help is greatly appreciated!
Maybe this description can help you?
appcmd set config /section:httpRedirect /exactDestination:true | false

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