Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Head canonical tag locking site


nettulf - 7:34 pm on Feb 6, 2013 (gmt 0)


What you need is some code that "computes" the page you are on.

On my shared hosting I have the following code that works on all my pages and subdirectories, even between websites. Maybe you could try?

NB it might give a different result on your host, so make a backup first and look at the output. Maybe show the output here if it does not give the correct result? Put it somewhere between <head> and </head> in the include above.


<?if( basename($_SERVER['PHP_SELF']) == "index" ):?>
<link rel="canonial" href="<?='http://' . $_SERVER['SERVER_NAME']?>">
<?else:?>
<link rel="canonial" href="<?='http://' . $_SERVER['SERVER_NAME'] . parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH)?>">
<?endif?>


Edit: Just tested and seems like the if-statement is unnecessary, it shows the homepage correct without it. But the code works so I am leaving it in. :)

[edited by: nettulf at 8:00 pm (utc) on Feb 6, 2013]


Thread source:: http://www.webmasterworld.com/php/4541564.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com