penders

msg:4404777 | 4:12 pm on Jan 7, 2012 (gmt 0) |
Try SCRIPT_NAME instead of REQUEST_URI.
|
AlexB77

msg:4404792 | 4:45 pm on Jan 7, 2012 (gmt 0) |
Worked like it should have. Thanks! Is there any security risks with using following on static .html pages? <link rel="canonical" <?php function fetch_url() { $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; return $url;} echo "href=\"" . fetch_url() . "\">";?> |
|
|
penders

msg:4404798 | 5:42 pm on Jan 7, 2012 (gmt 0) |
Presumably you are parsing .html pages with PHP? I think this is OK regarding security. Just a thought.... however, you could tidy it up and define the function at the start of your script. It could be more useful if fetch_url() returned just the URL? Or have a function that returns the whole canonical tag? But if you are not using the function anywhere else then you don't need a function for this.
|
AlexB77

msg:4404828 | 8:18 pm on Jan 7, 2012 (gmt 0) |
I thought so too and decided against it. I think that instead I will just use it like below: | <link rel="canonical" href="<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];echo $url;?>"> |
|
|
|