I am new to PHP so hope this isn't too embarrassing, but also have a further different question. I'm trying to make it so that a link's HREF is generated differently depending on the page.
I.e. if the url is mysite/com/blog/, make the url ../ otherwise ../../ - so whenever I create new blog posts or pages, it will automatically chose the right URL and not create a broken 404 link.
Why does the below code not work? Is there a syntax error?
Also another question - the links on my new blog to my main website work but they link to my main website using https://www.example.com/somepage.html, and I'd rather it be like ../../somepage.html
-
is the full URL bad for my website? e.g. bad for SEO, or in analytics will it show as a bounce off my website if it was the full link and not if it was from ../ ?
thanks a million!
<li><a href="<?php $blog = “/blog/”; $currentpage = $_SERVER['REQUEST_URI']; if($blog==$currentpage) {http://google.com}else{http://yahoo.com}?>">About</a></li>