Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Unable to Change Permalink From Orginal Domain Name WordPress

  • REFUNDED

<strong>Situation:</strong>

I have a WP 3.0 Multisite instance working on a hosted server.

Backed up the instance and restored it to a local XAMPP 1.7.3.
Further Environment Specs are provided below.

Site is resolving locally, but with issues.

<strong>Problems:</strong>

1. None of the Public Pages are displaying, just the core site template with
no top nav for the Public Pages. If I login as admin I can see Public Pages.

When I browse to http://localhost/agents/wp-admin it redirects to
an ugly URL:
http://localhost/agents/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%2Fagents%2Fwp-admin%2F&reauth=1

Then when I attempt to login it sometimes redirects to the orginal URL on the hosted server (http://domainname.com/site).

I have to close the browser out and then re-browse to http://localhost/agents/wp-admin and login to get into the local site's Admin control panel.

2. I have attempted to change the PermaLink thru WP-Admin and it does not fix the situation. It continues to display the original site URL from the hosted server that I
backed it up from!


<strong>This is the process I followed to restore the MultiSite locally:</strong>


1. Copy all of the WP files into a new directory under htdocs

2. Search & Replace the site URL in the SQL file, replacing it
with http://localhost/site.

3. Change the site path definitions to localhost in wp-config:

define( 'DOMAIN_CURRENT_SITE', 'http://localhost' );
define( 'PATH_CURRENT_SITE', '/agents/' );

4. Import the SQL file into the newly created DB

5. Create the DB User with same DBUser and Pwd as in wp-config

6. Give DBUser ALL PRIVILEGES

7. Change the site URL's in wp_blogs and wp_option tables

=== Environment Spec ===

###### Apache Friends XAMPP (Basis Package) version 1.7.3 ######

+ Apache 2.2.14 (IPV6 enabled)
+ MySQL 5.1.41 (Community Server) with PBXT engine 1.0.09-rc
+ PHP 5.3.1 (PEAR, Mail_Mime, MDB2, Zend)
+ Perl 5.10.1 (Bundle::Apache2, Apache2::Request, Bundle::Apache::ASP, Bundle::Email, Bundle::DBD::mysql, DBD::SQlite, Randy Kobes PPM)
+ XAMPP Control Version 2.5.8 (ApacheFriends Edition)
+ XAMPP CLI Bundle 1.6
+ XAMPP Port Check 1.5
+ XAMPP Security 1.1
+ SQLite 2.8.17
+ SQLite 3.6.20
+ OpenSSL 0.9.8l
+ phpMyAdmin 3.2.4
+ ADOdb v5.10
+ FPDF v1.6
+ Zend Framework 1.9.6 Minimal Package (via PEAR)
+ Mercury Mail Transport System v4.72
+ msmtp 1.4.19 (a sendmail compatible SMTP client)
+ FileZilla FTP Server 0.9.33
+ Webalizer 2.21-02 (with GeoIP lite)
+ apc 3.1.3p1 for PHP
+ eAccelerator 0.9.6-rc1 for PHP
+ Ming 0.4.3 for PHP
+ PDF with pdflib lite v7.0.4p4 for PHP
+ rar 2.0.0-dev for PHP
+ Xdebug 2.0.6-dev for PHP
+ libapreq2 v2.12 (mod_apreq2) for Apache


Answers (5)

2010-12-07

John Cotton answers:

Shouldn't this define( 'DOMAIN_CURRENT_SITE', 'http://localhost' ); be

define('WP_HOME','http://localhost');
define('WP_SITEURL','http://localhost');


Project Admin comments:

These define statements were already there from when we implemented the site (Remember this is WP 3.0 MultiSite, not Stand-Alone).

I only changed the variables from:

define( 'DOMAIN_CURRENT_SITE', 'http://domainname.com' )
define( 'PATH_CURRENT_SITE', '/agents/' );

to:

define( 'DOMAIN_CURRENT_SITE', 'http://localhost' )
define( 'PATH_CURRENT_SITE', '/agents/' );

I took your suggested and commented out the original define statements and
tried both:

define('WP_HOME','http://localhost');

define('WP_SITEURL','http://localhost');

and:

define('WP_HOME','http://localhost/agents');

define('WP_SITEURL','http://localhost/agents');


Error: Parse error: syntax error, unexpected T_STRING in wp-config.php online 76.

I have also made sure the WP_blogs Site URL and the WP_Options URL in the DB have been changed to "localhost" from the original domain URL.



John Cotton comments:

wp-login.php has a hidden field in it (redirect_to) the contents of which gets affected by various filters depending on exactly what the login form is doing (eg $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );).

I've have a look at the source of the page next time you're logged out and see what value that's been set to. Then have a look through the code for something that's responding to whichever filter has been activated for that state.

2010-12-07

Bob answers:

CLEAR your cookies!

If that does not work,

you can add this to your config @define('ADMIN_COOKIE_PATH', '/');

If that doesn't work try changing the path in the above for '/' to your directory.

Read this http://codex.wordpress.org/Login_Trouble

ps.make sure you clear you browser cache and disable all plug-ins.


Project Admin comments:

@BOB - Tried everything you provided. We are closer after applying the Site URL Redirecting fix found on http://codex.wordpress.org/Login_Trouble

So redirecting when trying to login to wp-admin is fixed.

My links in the theme are now referencing localhost as expected.

However, I have broken links when clicking on them!

"Browser can not display" errors, but not WP 404 errors.

I have validated in wp-admin that the links are referencing the permalinks to the Pages in the WP site, so don't understand why I am getting broken links when the link it referencing is appearing in the browser address bar as expected.

I have also confirmed in Settings > Permalink that it is now showing http://localhost as expected.


Project Admin comments:

I have disabled all plugins and issue remains with regards to broken links.

2010-12-07

Kannan Sanjeevan answers:

Login to Admin account . Go to General Settings and change the word press url and site url to http://localhost/agents . This should fix the problem . Revert back if it doesn't fix the issue


Project Admin comments:

Another Interesting Issue

Cleared browser cookies/cache...closed out browser.

Restarted browser and browsed to http://localhost/agents...then added "wp-admin" and logged in locally to the admin control panel. Works as expected.

I then close browser out.

Re-open and browse to http://localhost/agents. I click on a sign-in link we have in the theme that references: http://localhosts/agents/wp-login.php...I then try to login as admin and it redirects to be to the hosted site on the domain URL.

Either way...the other links are still broken...even though they appear to reference as expected.


Kannan Sanjeevan comments:

Can u mail me the backup of the site to kan [ at ] cre8tivenerd [dot] com so that i can try it in my local host and come up with a solution .


Project Admin comments:

@Kannan - Yeah, sure.... let me zip that up with my credit card info and send it over.

2010-12-07

mouad achemli answers:

get backup for your database

and open your database_backup.sql with any editor notepad+ or editplus

find and replace your ex domain with localhost

exemple :

http://domain.com/ to http://localhost/



Project Admin comments:

@Moud - Yes I did that as part of my migration process and the site runs. I have even checked all of the DB tables looking for areas where the site or blog URL is still pointing to the domain URL and I can't find any.


mouad achemli comments:

first get backup of your database

and try to change link under general-setting to localhost/agent from your webhosting

and get your new backup and install localy

2010-12-08

Peter Michael answers:

Login to wp admin. Go to Settings -> Permalinks and update your permalink structure. Also, what's in your .htaccess file?


Project Admin comments:

@Peter - I did this right after the migration process as this is typically a step that is neccessary to "true up" the Permalinks...but the Permalinks would not change. That is until I tried the fix for Site URL Redirecting fix found on http://codex.wordpress.org/Login_Trouble.

What is still baffling me is that now the Permalinka show the http://localhost, also when you hover all links displaying on the site they show reference to http://localhost. However, they are broken when you browse the links.

I can login to wp-admin with no issues and my permalinks are set to Custom Structure

/blog/%category%/%postname%




Project Admin comments:

<strong>.htaccess Contents</strong>


# BEGIN WordPress
RewriteEngine On
RewriteBase /agents/
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

# END WordPress


Peter Michael comments:

Do the links work when you disable pretty permalinks?


Project Admin comments:

@Peter - Oddly the links do work when I changed the Permalinks to Default.

All site links work, except the hard coded links like in the footer that still reference the http://localhost/agents/somepage.


Peter Michael comments:

OK, I suggest you to run your local copy on a virtual host and then try again, I've seen strange things when running WPMU on localhost. First, you need to edit your hosts file which is usually in 'windows\system32\drivers\etc\'. Add two entries like '127.0.0.1 mydomain.lan' and '127.0.0.1 www.mydomain.lan'. You may want to use your real domain and just change the .com to .lan

You then need to add your virtual host to 'httpd-vhosts.conf' in 'xampp\apache\conf\extra'. An example host:

<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit

ServerName mydomain.lan
ServerAlias www.mydomain.lan
DocumentRoot "path/to/www"

ErrorLog logs/mydomain.lan.error.log

<Directory "path/to/www">
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>


After you have set up your host, again replace all occurrences of the domain name to the new local domain name. The re-import the SQL file to your DB again (delete all tables first) and update your permalink structure after login to your wp-admin.

HTH


Project Admin comments:

1. Changed hosts file to use original domain URL:


127.0.0.1 localhost
127.0.0.1 domainurl.lan
127.0.0.1 www.domainurl.lan


2. Changed httpd-vhosts.conf as recommended

3. Changed the URL reference in the backup SQL
from http://domainurl.com/agents to http://domainurl.lan/agents

Site does not come up now

I think I am done chasing this....until I have more time to test how best
to migrate WPMU from localhost to hosted host and back again...I am sticking with single site instances.