Solutions to missing leading slash in URLs
-
Hi there,
NGG will appear to not load properly, the options pages don’t display, things just won’t work because none of the assets are being loaded. This is because the URLs are to those files look like example.comwp-content and in my case this is due to a conflict between the get_static_url function and a setting in the Roots theme which enables relative URLs.
I just spent a couple hours or more searching far and wide to figure this out so I thought I would post it here to potentially save the next person who goes on this journey some time. I saw lots of people with a similar issue but no solutions. Here are the solutions.
Solution 1
If using the Roots theme comment this line out or remove it from your Roots config.php file:
add_theme_support('root-relative-urls');
Solution 2
If you aren’t using the Roots theme and are having the same issue you may have some other code in your theme or a plugin which does a similar thing. Therefore, if you don’t want to or can’t change that option without breaking other things or you aren’t using the Roots theme and can’t figure out what’s modifying your URLs then you can also modify NGG’s get_static_url function like I’ve shown below.
Around line 156 of this file in NextGEN Gallery Version 2.1.23
/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/mvc/package.module.mvc.phpChange:
return $retval;
To:
return ($retval[0] != "/") ? "/" . $retval : $retval;
Good luck!
Ryan
- The topic ‘Solutions to missing leading slash in URLs’ is closed to new replies.