Jump to content

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


MarcC
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 year later...

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?

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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