Having separate themes - if the same host address has www. and a version with no www. - asp.net

I have a set of themes for my website, which are to be used with different requests from different urls. So if the url = www.xyz.com I load a different theme, as opposed to www.abc.com.
However, I have tried having a theme called www.abc.com and a theme called abc.com, and in my webform codebehind I have a preinit page event which says if url.contains(abc.com), then load theme abc.com, if url.contains(www.abc.com), then load theme www.abc.com (valid theme).
Starting from the beginning again, what is the best way to have and call a theme depending on whether the url has www. or not, but the same host. So how can I have separate themes for abc.com and www.abc.com, and then load the latter when the url is www.abc.com and the former when the url, is obviously, abc.com?

Not exactly sure what you're after here, but if you are testing the url in that order, and using an else, then it looks like the first case will always be true, so test for the more specific case (www) first.
Would also suggest that you look at testing for url.StartsWith, and include the protocol variations that you might expect, as you never know if those strings might show up somewhere else in the url in a year or two, and your theme switcher might stop working.
You could then just swap around master pages to change your theme, or if you are using the App_Theme thing, do some switching on that. Always found the aspnet theme thing to be a little bit clunky myself.

Related

How to disable default url structure (page_id=id) in Wordpress and just use permalink structure

I would like to stop WordPress from redirecting the default URL pattern example.com/?page_id=id to the permalink. I would like it to result in a 404.
I don't want that users are able to find single pages by brute forcing my URL structure in a way that they are just trying out URLs with various page_ids.
My goal is to be able to use "hidden" pages with a random slug, so that only people who know the URL will be able to find the corresponding page. But if the pages are accessible via the page id that wouldn't make much sense.
I assume that there is a way to do that in WordPress itself. I don't want to use web server redirects like with the htaccess file, because I want it to be coupled more tightly with the wordpress application. In my experience htaccess files are sometimes messed up by inexperienced users. I want to prevent that the page_id redirections are accidently re-enabled if the htaccess gets messed up unnoticed.

Mixed Content: The page at 'https://example.com' was loaded over HTTPS, but requested an insecure stylesheet error in Wordpress site

Instead of genuine Mixed Content issue this seemed like more of a Wordpress issue hence posting here to find a resolution.
I have everything setup to work with https, though there is no valid certificate yet. here is the home page url https://tourpoule.nl. The home page loads but with Mixed content errors which seem to be generated by core Wordpress or theme functions. Attaching image:
Database does not have any url which would start with http://. I already have replaced them using search and replace script.
There is nothing in htaccess file except basic Wordpress setup code. I tried renaming it as well. I cleared all types of cache but still it does not work. The site is using twentytwenty theme and if I comment out css and javascript enque lines, some of the errors disappear but styles and scripts do not load(that is normal I know).
In the view source of page it shows mixed urls, some with https and style and javascript urls without https. see below:
Interestingly if I click a stylesheet url i.e. http://new.tourpoules.nl/wp-content/themes/twentytwenty/style.css?ver=1.0 it redirects to https://new.tourpoules.nl/wp-content/themes/twentytwenty/style.css?ver=1.0
I am not sure what is going on and have got struck. I am not able to reach the client so that we can discuss turning ssl redirection off in nginx for this domain where it is redirecting everything to https if it is not https. Not sure if that is causing issue (I believe it is not as it has nothing to do with Wordpress mechanism to generate urls). Any help or direction is greatly appreciated.
I can see your website is still unsecured, for what it's worth, get yourself letsencrypt ssl.
Back to you question, go to your database, open the wp_options table, change the siteurl item to https://tourpoules.nl and also change the home item to https://tourpoules.nl.
If you have used search and replace DB master script or plugin it will not update inside meta files as well as and check for the function file have you Enqueue with https://
So will be better if you download SQL file and replace with below:
From:
http://new.tourpoules.nl
To
https://new.tourpoules.nl
and re-upload again

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 network site URL handling

I have a szenario I don't know how to solve.
I have installed a MU Wordpress site.
First problem - site path
I have two sites "www.powerdoo.com" (site1) and "www.powerdoo.com/de-de" (site2).
But I want that my main site also has default path, so the result should be "www.powerdoo.com/en-us" (site1).
Inside the network "sites" settings it is not possible to change the path for the main site.
How can i solve this?
Second problem - web.config redirect
It my first problem is solved I now want the URLs Redirect like this:
www.powerdoo.com -> www.powerdoo.com/en-us
www.powerdoo.de -> www.powerdoo.com/de-de
Can anybody help me how I have to write a rule for this?
Thanks Steffen
In that case you need to map the domains to the respective wp sites and have rewritten the base url.
This plugin will help you out to achieve those redirects, is extremely easy to set up and also it will take care of the base url rewrites.
https://wordpress.org/plugins/wordpress-mu-domain-mapping/
This way your sites will work fine with both URLs (www.powerdoo.com -> www.powerdoo.com/en-us) and most probably you won't need to mess up the theme's code.
The only thing you need to be aware of is that "if it gets to happen"
that on some places of your theme the base url rewrite doesn't work it
will be most probably due to the way the original url is generated by
WP engine inside of the theme. But if you are php handy you will be
able to fix it on the theme or the child-theme with a
str_replace();.

Wordpress, why doesn't my blog load the posts if U use the /subfolder domain method?

I have a blog at http://hamids-it.elaosta.com amongst others. If I try to access it from
http://elaosta.com/hamids-it it loads the blog but says it couldn't find the page I wanted.
How do I fix this so I can use either?
I'm guessing you have a standard subdomain install, whereby http://subdomain.example.com is mapped to the directory /example.com/public_html/subdomain?
In any normal circumstance, say with a static HTML file, you can rightly access the same resource at both example.com/subdomain/resource.html and subdomain.example.com/resource.html.
However, in your case, WordPress is parsing the REQUEST_URI and using it to determine what to show.
So in the case of http://elaosta.com/hamids-it, WordPress is actually looking for a page 'hamids-it' - and if it doesn't find it, voila, your 404.
The fix?
You'll need to decide which way you want to access your blog, subdomain or sub-directory, then stick to it.
When you've made a choice, update your General settings in WordPress admin and set both address URL's to either http://hamids-it.elaosta.com or http://elaosta.com/hamids-it.

Resources