• Is it possible to redirect my domain name – pjnphoto.com to a subfolder (/pjnphoto) to keep my old site live while I redesign my new site based on wordpress in the root using the ip address http://66.147.244.61/~pjnphoto/
    ?
    The problem: The htaccess redirect to subfolder worked but after I installed wordpress – code was added to the end of the htaccess file – see begin and end of wordpress code below. I don’t understand this code but it’s causing the live site (redirected to the subfolder) to throw a 500 error but the ip address is still pointing to the root/new wp redesign which is currently under development. If I remove the code both ip and domain name resolve correctly but I’m not sure what I am breaking by removing the code.

    My main interest: I need to redirect my domain name pjnphoto.com to a subfolder while I redesign a new site i nthe root using wordpress – any suggestions? Maybe I’m going about this wrong. Thx

    # Use PHP5.4 as default
    AddHandler application/x-httpd-php54 .php
    # BlueHost.com – all lines above are the original code lines before this below edit to redirect to subdirectory
    # .htaccess main domain to subdirectory redirect
    # Do not change this line.
    RewriteEngine on
    # Change example.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?pjnphoto.com$
    # Change ‘subdirectory’ to be the directory you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/pjnphoto/
    # Don’t change the following two lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Change ‘subdirectory’ to be the directory you will use for your main domain.
    RewriteRule ^(.*)$ /pjnphoto/$1
    # Change example.com to be your main domain again.
    # Change ‘subdirectory’ to be the directory you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?pjnphoto.com$
    RewriteRule ^(/)?$ pjnphoto/index.html [L]
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~pjnphoto/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /~pjnphoto/index.php [L]
    </IfModule>

    # END WordPress

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ccarlow

    (@ccarlow)

    Additional helpful: Could someone explain to me why wordpress adds the below code to my htaccess file and what exactly is it trying to accomplish?

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~pjnphoto/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /~pjnphoto/index.php [L]
    </IfModule>

    # END WordPress

    Thread Starter ccarlow

    (@ccarlow)

    Ok I think I solved the problem and will post it below. I simple encapulasted the begin/end wordpress code in the htaccess file with an <IfDefine ip address> – I redirected the domain name pjnphoto.com to a subdirectory and I use the ip address in the root to develop a new wordpress site. the IfDefine only allows the Begin/Edn wordpress code to run if ip is defined so that when pjnphoto.com is used in the url it gets redirected to the subdirectory.

    # Use PHP5.4 as default
    AddHandler application/x-httpd-php54 .php
    # BlueHost.com – all lines above are the original code lines before this below edit to redirect to subdirectory
    # .htaccess main domain to subdirectory redirect
    # Do not change this line.
    RewriteEngine on
    # Change example.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?pjnphoto.com$
    # Change ‘subdirectory’ to be the directory you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/pjnphoto/
    # Don’t change the following two lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Change ‘subdirectory’ to be the directory you will use for your main domain.
    RewriteRule ^(.*)$ /pjnphoto/$1
    # Change example.com to be your main domain again.
    # Change ‘subdirectory’ to be the directory you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?pjnphoto.com$
    RewriteRule ^(/)?$ pjnphoto/index.html [L]
    # if ip goto wordpress site in root; when domain name pjnphoto.com is # used – goto subdirectory where live site is temporarily located
    <IfDefine 66.147.244.61>
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~pjnphoto/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /~pjnphoto/index.php [L]
    </IfModule>

    # END WordPress
    </IfDefine>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘redirect domain to subfolder while build new root’ is closed to new replies.