Jump to content

Cre8asiteforums

Web Site Design, Usability, SEO & Marketing Discussion and Support

  • Announcements

    • cre8pc

      20 Years! Cre8asiteforums 1998 - 2018   01/18/2018

      Cre8asiteforums In Its 20th Year In case you didn't know, Internet Marketing Ninjas released many of the online forums they had acquired, such as WebmasterWorld, SEOChat, several DevShed properties and these forums back to their founders. You will notice a new user interface for Cre8asiteforums, the software was upgraded, and it was moved to a new server.  Founder, Kim Krause Berg, who was retained as forums Admin when the forums were sold, is the hotel manager here, with the help of long-time member, "iamlost" as backup. Kim is shouldering the expenses of keeping the place going, so if you have any inclination towards making a donation or putting up a banner, she is most appreciative of your financial support. 
DonnaCavalier

Url Rewrite Help Needed

Recommended Posts

I'm working on a major conversion project (from one cms to wp) in which the client needs the url structure to remain the same for the existing pages that I will be importing (new pages don't need and shouldn't have this done to them).

 

So, let's say the urls are like this (about 1,000 total):

 

http://www.somedomai...05/somepage.htm

http://www.somedomai.../2387/apage.htm

 

In all cases, the http://www.somedomain.com/pages remains the same.

 

I want to import the content that will create urls like this:

 

http://www.somedomain.com/somepage/

http://www.somedomain.com/apage/

 

That's the easy part.

 

Now, I need to do three things to rewrite these urls so they match the original structure.

 

1. add /pages/ after http://www.somedomain.com for all the urls in this list (not all new urls going forward, just this initial list of 1000 or so)

 

2. add the number between pages/ and the pagename, with each number being unique to the pagename, so i'll need to manually type all 1000 or so in.

 

3. remove the trailing / and add the .htm to the end (again, only to this list of 1000 or so, not all future urls)

 

Any thoughts on how to write the URL rewrite code to make this happen? I'm brain dead on this matter, and just can't seem to wrap my head around it. All help appreciated.

 

Hope I was clear. No guarantees on that. :)

 

dd

Share this post


Link to post
Share on other sites

Well...I guess you win the award for stumping everybody! I can vouch that Eric saw your questions but didn't think he was qualified to help because he thought he needed more experience with WP.

 

:dazed:

Share this post


Link to post
Share on other sites

OK, I've read the OP a number of times and I'm not certain that I understand...

 

Are these imported pages existing ones that will require 301s to pass through existing values?

Why does importing the URLs change the name from, i.e. http://www.somedomain.com/pages/200005/somepage.htm to http://www.somedomain.com/somepage/ ?

 

Colour me confused.

 

If 301s are not required then I'd run the files names through a script that restructures/names as wanted then upload already corrected. But if this is impractical for whatever reason...???

Edited by iamlost

Share this post


Link to post
Share on other sites

Well, I don't know how to explain why the import process doesn't add the appropriate url folder info - It just doesn't. Nothing I do beforehand will change that, afaik. And I've even tried manually changing the wordpress post slug to add in the /pages/12345/ portion before the postname in the url, but wordpress simply strips the slashes and makes the slug pages12345postname instead. So even if I wanted to manually change 1000 slugs, it wouldn't work. So that's why I was assuming that what I need to do is handle it via URL Rewrite in the .htaccess. Make sense?

Share this post


Link to post
Share on other sites

Ouch!

The numbering part is the kicker in the 'easy:hard' ointment: can it be sequential? Like starting at 2225 and going to 3224 (if a thousand pages) or are the numebers specific and out of sequence? Does it matter which number gets stuck to which page? If so can you import them in the wanted order?

Share this post


Link to post
Share on other sites

It cannot be sequential or randomly assigned. It does matter which number gets stuck to which page, and it's not a perfect sequence. So there are gaps between numbers. I'm willing to create a full list of all 1000+ pages in htaccess. So if I can just figure out the basic formula for adding the pages/12345 portion up front and the .htm portion at the back, I can start constructing the list of rewrites.

 

If all else fails, I'll tell the client he has absolutely no choice but to accept that the urls will not remain the same, and he'll have to settle for 301 redirects, but I know he's going to go postal if I tell him that. So, I'd rather find the help of a url rewrite guru if at all possible first.

Share this post


Link to post
Share on other sites

Is it possible to split each directory part out into seperate columns in the spreadsheet and then delete out the number one? Then a few find and replace commands should sort the rest out?

Share this post


Link to post
Share on other sites

Not sure I get what you're saying, Jon.

Share this post


Link to post
Share on other sites

Thanks! I'll try that tomorrow and let you know.

Share this post


Link to post
Share on other sites

Woke up knowing I'd gone way wrong...

 

The above code won't help, if I understand your problem, because it will be attempting to redirect to a non-existent URL.

The import creates /somepage/ . That will exist. Simply pointing/redirecting users to where you would like it to be instead won't fly.

Given the numbering problem I see the options as either:

* manually changing each imported directory URL to the desired page URL.

* downloading page content then uploading to desired page URLs.

* possibly using htaccess alias to rename each internally.

 

I have meetings for the first part of this morning so can't look at this again until later if it remains unsolved.

Note: that won't actually 'move' the content.

Share this post


Link to post
Share on other sites

Keep in mind that with WP, these things don't "exist" anyway in an actual folder structure anyway. It's all just content in a database and the url is pretty much bogus to begin with. But you're right, in that if someone links to the url, then WordPress would sure as heck need to know where it refers to.

 

I don't know. At this point, I'm not sure this is possible at all.

Share this post


Link to post
Share on other sites

I just had a thought, and since I've just woken up, it may be a ridiculous one, but I'll document it here before I forget it anyway.

 

What if I simply made a Pages category, with a thousand child categories, each one being the 12345 part?

 

Then, once I import all 1000 posts, I can just go assign each one to the child subcat (the number), and if the permalink structure is /%category%/%postname%/, then that should assign it /pages/12345/posttitle, i think.

 

In fact, I could add the .htm there too = /%category%/%postname.htm%/

 

Any new posts could just be assigned to a different category that has nothing to do with the Pages category if he'd like.

 

That might work if all the imports are imported as posts and not pages. That wasn't how I'd planned to do it, but it might be how I plan to do it now. :)

 

Ok, off to get coffee in me, and revisit this when the brain is awake.

Share this post


Link to post
Share on other sites

What if I simply made a Pages category, with a thousand child categories, each one being the 12345 part?

 

Then, once I import all 1000 posts, I can just go assign each one to the child subcat (the number), and if the permalink structure is /%category%/%postname%/, then that should assign it /pages/12345/posttitle, i think.

 

That's how I probably would have done it.

 

I wonder, though, if you could not have used hyphens in the slugs and then used a rewrite rule to convert slashes to hyphens.

Share this post


Link to post
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


×