I need my website to have different URLs depending on the country you're accessing it from; it would work like this:
www.mypage.com ==> for users accessing from Spain - content in Spanish.
www.mypage.com/en-uk/ ==> for users accessing from UK - content in English.
www.mypage.com/en-br/ ==> for users accessing from Brazil - content in English.
www.mypage.com/en-il/ ==> for users accessing from Israel - content in English.
As of now there are only two versions of the web (Spanish and English), so for all specified countries (except Spain) the different URLs should point to exactly the same content. I'm trying to find a solution that doesn't involve having the same content copied 3 times.
I'm trying to to this with the following plugins:
WPML
Geo Redirect
But I'm struggling to make it work. I understand the problem may seem a little vague, it's just that I'm pretty lost and I'm not sure how to approach this. All suggestions would be appreciated.
Try using a redirected URL. You can create the other (non-content) pages (www.mypage.com/en-il/) and add to the header a redirect:
<html>
<head>
....
<script>
// this will load the corresponding page
window.location.assign("http://www.mypage.com/en-uk/");
</script>
</head>
<body>
<!-- empty -->
</body>
</html>
Here is a second example where you can do the redirect from a single 404 page. Just place this code at the top level (home) of the web site in a page named 404.shtml
<html>
<head>
<script>
window.onload = function()
{
// Get the referring URL
var ref = '<!--#echo var="REDIRECT_URL"-->';
// Break into components
//
comp = ref.split('/');
if ( comp.length > 1 )
{
switch ( comp[ 1 ] )
{
case "en-br":
case "en-il": // this will load the corresponding page
window.location.assign("http://www.mypage.com/en-uk/");
break;
}
}
</script>
</head>
<body>
<!-- 404 page handling here -->
</body>
</html>
Related
I have wordpress on the Github pages, what I like to do is to set custom 404 error page created with Wordpress.
But every plugin doesnt work for me. I can use any plugin to set custom 404 page, but it will open the default github pages 404 page.
Also I want to create Redirections with Redirection plugin, but it also doesnt work for me it wont open the url I have set, it will open default 404 github page.
I'm using Wordpress 5.6.
Can you help me to solve this problem?
If you want to redirect your Error 404 page, then make a file called "404.html". And paste the code:<meta http-equiv="refresh" content="0;url=https://new-page-url.com"/>
EDIT:
If you want to redirect your Error 404 page to your home page, then paste this code:<meta http-equiv="refresh" content="0;url=/">
Advantages:i. One line code.ii. You can delay the timing of redirection according to your need by replacing the 0 from the code.
And the second one to redirect (used by you,I have excluded the above code) :
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<script type="text/javascript">
window.location.href = "https://zigecek.github.io/error"
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow <a href='https://zigecek.github.io/'>this</a>.
</body>
</html>
Advantages: I do not know.Disadvantages:i. The page will not be redirected if javascript is disabled in the users device, and the other content will be visible.At last, I would like to recommend you that do not make a redirection 'Error 404' page, instead you can make a responsive Error 404 page using Codepen or Google
Good day,
I'm sorry if this might be a duplicate question but most of the questions speak of Google AdSense and I've never used that.
Getting to the point, I would like to know if anyone knows how to add an advertisement from Google to an HTML 5 site.
I am doing a project. The actual site files will be on the local drive, but I would like to i.e. insert an on my page that would draw some random Google Ads and place them in this section.
I do not wish to create an advert or anything of the sort. Let's say that I have the section at a 600px by 100px block, I would like to have that "draw" any ads of a certain category to be placed there at run time.
Like I said the page itself will be local, but using internet access the page should fetch these ads.
Thank you in advance for a speedy reply, and I would like to apologize if I over explained.
It is very easy to insert the Google Adsense in HTML just paste your code inside the body tag and use bootstrap or CSS3 for the positioning.
<html>
<head>
This is the head of your page
<title>Example HTML page</title>
</head>
<body>
**Paste your google adsense code inside the body**
This is the body of your page.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Homepage Leaderboard -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>
Refer Get and copy the ad code (click "If you haven't yet created an ad unit under "How to get and copy your ad code")
Then refer Where to paste the ad code in your HTML
It's explained pretty well
<html>
<head>
This is the head of your page
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.
<!-- Ad block -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- End of Ad block -->
</body>
</html>
Adsense can not be loaded from localhost or from a saved html file. It will not work.
Google checks if the domain is accepted into adsense before showing an ad.
So when you load an ad from local, domain property will be missing.
Some random has purchased a .com domain and I own .net. he has posted an iframe on the site linking to mine, and at the top of if he has posted that "This site is for sale" and I need to stop this happening. is it possible to use PHP or javascript to stop that particular site from either accessing my site, or redirecting his iframe to somewhere else.
Thats easy:
Say he use your file this way
a.html
<html>
<body>
<iframe src="sample.html"/>
</html>
just add the following lines to your already existing on Document load function:
window.onload = function(e) {
if ( window.self !== window.top ) {
//Your site is in i frame
//just redirect to his own site if you feel like there will be an endless recursion so nothing will load probably.
//You can put your custom action if this is not what you want
window.self.location = "a.html"
//would be pretty good enough :D
}
};
This is the open graph image I want to load on all my pages shared on Facebook. It is loading properly on some pages and on others it is choosing a random image from the page. Below is the OG URL. I am using Drupal CMS for my site. All the proper code seems in place.
http://www.vaeducationoxnard.com/sites/default/files/styles/square_thumbnail/public/Charter%20Square%20Logo.png
This is because, facebook sends the whole new request to the url you are passing and because of this it gets the image from og:image in which you have passed the default image. To overcome this, try to aadd the image parameter in the url you are passing
Ex. your/url?imgToShare=
And in the main page from where you set the meta tags, add one condition
<?php
if(isset($_REQUEST['imgToShare'])
{
<set the meta tags for image you want>
}
else
{
<meta tag with the default image>
}
?>
This helped me.
Please comment if you have any doubts.
I am playing with Wordpress 3 for the first time and had a quick question.
I am placing ads on a site and wondered the best practice to add in the script. The code that Google generates is in 2 parts, one for the of the page and one where the ad should go
The head code is in the form
<script type='text/javascript' src='http://partner.googleadservices.com/gampad/google_service.js'>
</script>
<script type='text/javascript'>
GS_googleAddAdSenseService("ca-pub-123123");
GS_googleEnableAllServices();
</script>
<script type='text/javascript'>
GA_googleAddSlot("ca-pub-123123", "300x250_Ad");
</script>
<script type='text/javascript'>
GA_googleFetchAds();
</script>
Then the code for the ad is:
<!-- ca-pub-123123/300x250_Ad -->
<script type='text/javascript'>
GA_googleFillSlot("300x250_A");
</script>
I downloaded a plugin Advertising Manager that allows me to add ads into the page but only seems to allow putting in one block of code. I can add all the code joined up but if I want to add other ad positions later it is not the best...
I can't go into my Theme and add the code in there, as I am using Multiple Sites the code will need to difer from site to site, is there something very simple I am missing to add stuff into the and then I can use Advertising Manager to display the individual ad code...
Try using the the AdSense-Deluxe WordPress Plugin
It would appear the plugin has a bug, the shortcode you're using is calling a function which is directly outputting the code for DFP (which is called when wordpress is preparing the page content, hence it appearing all at once at the top) instead of returning it to be inserted throughout the content.