WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] relative path (6 posts)

  1. shadowdroid
    Member
    Posted 5 years ago #

    Hi,

    as I read in some of the other entries ABSPATH is a dynamic global which changes in the wp-settings.php.
    I am encountering the problem that the blog always seem to refer to the main host directory based on the apache vhostsettings (just a guess).

    The site I am editing should have an entry site so i added an index html.
    which forced by the apache was allways picked on any submit (wp-engine)
    So i implement a cookie which was set by clicking on the "enter page"
    not a good solution after all.

    So what i want to do is move the blog in a subdirectory
    - /[DOC_ROOT]/index.html -> refers to /[DOC_ROOT]/wordpress/index.php

    which basicly did work only that the file paths still didn't change

    Therfore the final question : " Would changing the ABSPATH to a static Variable (hardcoded) inflict the blog in any point ?"

    thanks j

  2. WebDev WaxLotus LLC
    Member
    Posted 5 years ago #

    The ABSPATH variable is defined in the wp-config.php file:

    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    require_once(ABSPATH . 'wp-settings.php');

    It uses the PHP function dirname to return the name of the (in this case '/') directory it's checking.

    So if you use a subdomain, e.g. /wordpress/ or /fredsblog/ it will return the name of that directory.

    By 'entry site' I'm assuming a splash page or some other site. Putting WP in a subdomain/folder is a good idea then, as you can turn the index.html or whatever in the domain root to a full site and keep the blog files in their own folder.

    If you're still having trouble after installing WP in its own folder then either the install is wrong (possibly config file) and/or you have .htaccess files/vhost/symlink malconfig issues.

    You should not have to hardcode the ABSPATH variable. IF you do, you're covering up a stink by spraying perfume on it...

  3. shadowdroid
    Member
    Posted 5 years ago #

    lol thanks :) i like the metaphoric picture about the perfume,

    but it's not a subdomain just a subtree,
    i know that dirname returns the directory name, i develope using php4/5, so in the theorie i could get the relative path with getcwd() ? because this allways refers to the working directory while dirname returns only the pathname of the directory in which the file is.

    and just in case so that there will be no mistake -> i allready installed wp in the main directory the ideas is to move the fully functional site to a subdirectory. So everything is theoretical fine.
    I know the mysql structure and would replace the path strings maybee through a function or manual.

    or am I really forced to configure a subdomain for this site? what's your suggestion and sorry if I am causing any inconvenience.

    best regards j

  4. WebDev WaxLotus LLC
    Member
    Posted 5 years ago #

    So you're moving a root install to a subtree/folder install.
    You're correct, you do not need to use a subdomain as long as your config settings point to the new folder (/[DOC_ROOT]/index.html -> refers to /[DOC_ROOT]/wordpress/index.php)

    So you created the /wordpress/ folder and moved all of the WP files to that folder. You edited wp-config.php and edited/added:

    define('WP_SITEURL', 'http://www.sample.com/wordpress/');
    define('WP_HOME', 'http://www.sample.com/wordpress/');

    from here:

    'wp_siteurl' => array(
    						'value' => '',
    						'label' => __('WordPress address (URL)'),
    						'note'  => __('This value should exactly match the <strong>WordPress address (URL)</strong> setting in your WordPress general settings.'),
    						'prerequisite' => 'toggle_2_1'
    					)

    so you must also make the option change in your admin settings. You could do this on the db-backend too (PHPMyAdmin).

    For content changes there are plugins to do a global search and replace to update URI's (think about your attachments!)

    Look at this too...

    Is this closer to what you're looking for?

  5. shadowdroid
    Member
    Posted 5 years ago #

    absolutly :) thanks that was exactly what I was looking for
    many thanks to both of you for helping me out :)

    best regards J

  6. shadowdroid
    Member
    Posted 5 years ago #

    sorry ! many thanks to you! xD i was a bit hasty while typing

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags