Writing an index.php to ope an URL

Hi!
I want to link a button to another webpage. What i want is my domainname/folder/page/a function to direct to the other page
I thought that by doing a folder/page/index.php what directs to another page is a solutuon… now i tried this but nothing is happening…

nothing… white page… can someone please give me the code to let me open another url

Thanks!

Off Topic

@SEE: when you post code on the forums, you need to format it so it will display correctly.

You can highlight your code, then use the </> button in the editor window, or you can place three backticks ``` (top left key on US/UK keyboards) on a line above your code, and three on a line below your code. I find this approach easier, but unfortunately some European and other keyboards don’t have that character.

1 Like

Redirection fails because the PHP header() function must be called before the HTML script.

http://php.net/manual/en/function.header.php

1 Like

If the entire purpose of that page is to redirect to a different page maybe an htaccess redirect would do instead?

You mentioned a button, but I don’t see any in the image you posted so maybe I’m missing something.

2 Likes

This page may be useful.

1 Like

its a CMS, (osclass template) and in the back end i can put in a url to direct within the page,… /content/page it will direct to a specific page, but i want to direct to an external different page.

THANKS ! hey really thanks!

I simply made an HTML to open that page.
here is the code…

<!doctype html>
<html>
  <head>
    <title>Atmos4u</title>
    <meta http-equiv="Refresh" content="0; url=http://www.atmos4u.gr">

    <!-- If the meta tag doesn't work, try JavaScript to redirect. -->
 
    <script type="text/javascript">
      window.location.href = "http://www.atmos4u.gr"
    </script>
  </head>

  <body>
    <!-- If JavaScript doesn't work, give a link to click on to redirect. -->
 
    <p>If you are not redirected automatically, click <a href='http://www.atmos4u.gr'>here</a>.</p>
  </body>
</html>

(hey thanks Technobear !! worked with the ``` !)

HOW can you make it open in a new window?

-now my question, is there any reason to do that with php instead? it wors as it works now, and if yes with php, what exactly would be the code (complete copy of the example there)
thanks!

1 Like

The question is: How and why you want a redirect.
The page appears to have no purpose other than to redirect to somewhere else, so I would think there is no real reason for the page to even exist and just have a redirect in .htaccess to redirect that url as @Mittineague mentioned.
The php header should work, but that function must come before any html is output by the script. If that redirect is always to happen, then there is no use in the script subsequently outputting any html if the redirect has already happened, so again begs the question of why it should exist in the first place and not just be a server redirect.

1 Like

Sam I am really new to this,

that’s the page, please take a look… below the slider, if you click “περισσοτερα…” It should bring you to the sponsor page… whats the correct way to do it?

http://e-vape.deals/now/

Is there a reason why you can’t just link directly to the site in question? Personally, I dislike clicking what appears to be an internal link and then finding myself unexpectedly on another site.

1 Like

what does this mean?

those 3 positions will be from sponsors who will pay for that their shop get linked to that website.

Well, the usual way to link to another site is simply to create a direct link.

<a href="http://www.example.com">Visit our sponsor's site</a>

What you have is a link to an internal page (one on your domain) which doesn’t display, but simply redirects to the other site.

(By the way, are you aware of Google’s guidelines regarding buying/selling links? https://support.google.com/webmasters/answer/66356?hl=en)

4 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.