{"id":3236,"date":"2025-10-26T15:13:07","date_gmt":"2025-10-26T14:13:07","guid":{"rendered":"https:\/\/digitalia.culturanuova.net\/blog\/?p=3236"},"modified":"2025-10-26T15:22:01","modified_gmt":"2025-10-26T14:22:01","slug":"how-to-avoid-double-slash","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=3236","title":{"rendered":"How to avoid double slash"},"content":{"rendered":"\n<p>If your link points to a folder it should ends with a slash (\/), but if you use a php variable to define it and you sometimes need to add some page at the end of your link, you could have a problem: the double slash (\/\/).<br>I.g. you could have this variable php <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$mypath=\"mypath1\/mypath2\/\";<\/code><\/pre>\n\n\n\n<p>The final slash is recommended to avoid a redirect (that you would have with <code>$mypath=\"mypath1\/mypath2<\/code>).<br>And you can call that variable in all your webpages pointing at that folder, in this way:<\/p>\n\n\n\n<p>&lt;a href=&#8221;&lt;?php echo $mypath ?>&#8221;>some name&lt;\/a><\/p>\n\n\n\n<p>But if you have to point to a specific page in that folder, you shouldn&#8217;t use this code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;a href=\"&lt;?php echo \"$mypath\/a-specific-page.php\" ?>\">some other name&lt;\/a><\/code><\/pre>\n\n\n\n<p>otherwise you will get, in the final html, a double slash. No way, course to write <code>$mypatha-specific-page.php<\/code>\u00a0, because in this case your would call a not existing variable ($mypatha-specific-page.php\u00a0).<\/p>\n\n\n\n<p>A good solution could then be this<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;a href=\"&lt;?php echo $mypath . 'a-specific-page.php' ?>\">some other name&lt;\/a><\/code><\/pre>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If your link points to a folder it should ends with a slash (\/), but if you use a php variable to define it and you sometimes need to add some page at the end of your link, you could have a problem: the double slash (\/\/).I.g. you could have this variable php The final &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=3236\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;How to avoid double slash&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[885,751,566],"tags":[956,955,957],"class_list":["post-3236","post","type-post","status-publish","format-standard","hentry","category-code","category-php","category-webmaster","tag-double-slash","tag-slash","tag-variable-php"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3236"}],"version-history":[{"count":3,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3236\/revisions"}],"predecessor-version":[{"id":3239,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3236\/revisions\/3239"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}