Jump to content

How best to adjust URLs after pre-launch site was in subdir?


Recommended Posts

Posted

Let's say I develop a site in a subdirectory, like /newsite. Now I'm ready to launch the site and all of my TinyMCE link hrefs start with "/newsite". Is there a way to mitigate the need to go in and replace all of those with the correct address?

Posted

Page Link Abstractor is a splendid module, but it also introduces a rather big change to the way PW handles links. If you "just" want a one-time fix for changed links, it might be easier to run a simple SQL query for fields that contain changed links, replacing old links with new ones. Something like "UPDATE field_yourfield SET data = REPLACE(data, 'href="/newsite', 'href="');" should do the trick.

Since I'm not sure how familiar you are with MySQL / SQL in general, this may be self-evident to you, but still:

a) if you're not absolutely sure about what you're doing, don't try method I mentioned above and

b) always make a backup of the table you're working with before making any changes to existing data (CREATE TABLE backup_field_yourfield LIKE field_yourfield; INSERT INTO backup_field_yourfield SELECT * FROM field_yourfield;)

By the way, Page Link Abstractors description says that "This module hasn't yet been tested with migrating a site from subdirectory to root, but I will be testing this soon." Old information perhaps? :)

  • Like 2
Posted

Without SQL you could do it with simple bootstrap or in a template:

foreach($pages->find("template=basic-page") as $p){
   $p->body = str_replace("/newsite/","/",$p->body);
   $p->save();
}
  • Like 3
Posted

I have this same issue when doing one-time migrations of finished sites on my localhost MAMP/dev server (which runs sites off subdirs) to the live server. But the solution is really simple. When I export the database to an SQL dump (via PhpMyAdmin), I drag the resulting SQL file into TextWrangler/BBedit, and perform a search/replace: "/newsite/" => "/". Then I import it to new server (again via PhpMyAdmin). Problem solved on 5 seconds.

  • Like 2
  • 1 year later...
Posted

Performing replacement in database dump is a working solution.

But still, Is there a way to configure RTE to insert relative links instead so the replacement won't be even necessary? And make them relative to site root? I used to do it this way in Joomla, but it does not work in PW. If I manually correct the link to not start with "/" it becomes relative, but relative to the current URL, not the root. Can the desired be accomplished?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...