homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Help with An HTAccess Redirect
That needs to strip a?

WebmasterWorld Administrator 10+ Year Member

Msg#: 4441151 posted 11:02 pm on Apr 15, 2012 (gmt 0)

I am trying to save an entire copy of a site that runs on wordpress. I do not have access to the WP login or the Database so I used software to download a copy.

Now the issue I am having is that the original WP install never had any SEO changes done, so all of the pages are basically a query string URL.

I asked a member here to help me w/ it and we had no luck. It is more complex then a normal redirect / rewrite, since it has the query string in the url.

The original URLS are mapped like this:

When I took down a copy it saved them like this:

I can change all the files to be exactly what they used to be, but as an html format w/ out an extension: either as ?cat=3 or cat=3. These do not serve properly on the server. I get a 404 on the ? version and the raw source code on the non ? version.

I can also add .html to the file so it is ?cat=3.html / cat=3.html. When I do the ? it does not show (like a 404) and the other actually works... but I cannot figure out how to do a redirect from /?cat=3 to cat=3.html

Ideally if I could just upload my new files and have a 301 redirect to say the file has moved to a new location. The second best thing would be to have to change the file names.

Either that or keep the original file names, and somehow use code to tell the server to serve these pages as html file types.

I would also like to use SSI, on these pages so I am guessing that will be the next can of worms I will need to deal with.

Thank you!



WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Msg#: 4441151 posted 5:35 am on Apr 16, 2012 (gmt 0)

Ouch. OK, you've got "moderator" after your name so I guess that means my first thought is out: You're not swiping someone else's site wholesale :) And the second thing I was going to say was that query strings aren't in the URL, they're... Well, holy smokes. They're in the URL. But the format is consistent, so things are not so bad.

Either that or keep the original file names, and somehow use code to tell the server to serve these pages as html file types.

And that's the good news in a nutshell. You have been handed a priceless opportunity to hammer all names into the exact form you want. Global renaming offline is not an issue. I do it with-- of all things!-- a graphics program, but there have got to be other ways to deal with it.

:: detour to Forums Search ::

Post # 4434258 [webmasterworld.com] to be exact (second reply in thread). Read and assimilate.

Now, you don't have armies of customers pounding on the door wanting the site to be up and running yesterday, do you? Take the time you need to decide exactly what you want the names to look like. mod_rewrite does not lend itself really well to temporary fixes that you're planning to change next month. (Well. Actually the rewrite itself is not hard. But the googlebot never forgets. You can finish the thought yourself.)

Oh, and by absolutely amazing coincidence there's a post about Server Side Includes (can I assume you didn't mean Supplemental Security Income?) within the last couple of weeks in this very forum. I don't care for the line "If I can do it, anyone can" -- but I don't speak php and am deathly afraid of Terminal and nevertheless managed to get it done. So there you are.


WebmasterWorld Administrator 10+ Year Member

Msg#: 4441151 posted 8:59 pm on Apr 16, 2012 (gmt 0)

Thanks Lucy,

I asked a buddy (who also moderates here) for help on this and we have never had to deal with the ? before and that was causing some confusion. I will take a look at this and try a few examples out and see how it goes. Thank you for your help!

I would prefer to make it match 100%, but it seems like my server / doc types (? my guess as what is causing it). So I think it makes sense to do the 301 off the bat with a "hey all files now have .html tacked on the end and no longer have a ? in them") Then never look back.

Then if I ever go back to using WP for the site, and can create the permalinks to match this in the control panel.

As far as the SSI goes, is the the thread you were referring to:

I know in the past I have had to include something in an htaccess file to let .html files serve includes like a .shtml file. But that is really the extent of my experience. That is why I figured if I do not change these files to have .html at the end I would be into a pile of confusion when getting those to work.

I think a 1-time (or lifetime) 301 on these existing URLs is just the ticket. It just may be a few weeks for the might google re-adjust and adapt to the changes.

Thanks again!


WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4441151 posted 9:48 pm on Apr 16, 2012 (gmt 0)

The question mark is normally used to separate the path from the query string.

You cannot use a query string in the path. You will need to rename your physical files to remove it from the filename.

The equals sign is also not valid in the path part of a URL, You will also need to remove it.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved