- This topic is empty.
-
AuthorPosts
-
October 22, 2014 at 2:34 pm #186847lprintzParticipant
Hello all!
My client just signed on with Hubspot and they created a new blog for him and I need help with the .htaccess redirect
Old – http://www.eaglerockfinancial.net/blog/
New – http://blog.eaglerockfinancial.net/financialMy challenge is…I’d like to set it up as a ‘wild card’ so that I don’t need to redirect ALL his articles. The way the URLs are set up tells me this may be possible I hope. Here’s an example of an article…notice the similarity…
Old – http://www.eaglerockfinancial.net/blog/financial-life-track-divorce/
New – http://blog.eaglerockfinancial.net/financial/blog/financial-life-track-divorceCan this be done?
Thanks so much!
Len
October 22, 2014 at 4:36 pm #186850shaneismeParticipantI’m not sure if you can do this via .htaccess, but you can probably do this with code. For instance, in PHP, you can first collect the URL and use that as a variable to parse with whatever logic you need and then set the header to that new page with a 301.
You can actually use .htaccess to force all requests into a main
index.php
file that will handle the requests. Almost like a front-controller.October 22, 2014 at 7:20 pm #186862__ParticipantIt could be done with mod_rewrite, but it would require hard redirects (because they are different domains).
October 23, 2014 at 6:29 am #186899lprintzParticipantThanks for all your responses!
Chris, to answer your question, no idea! :)
This is just how hubspot set up their new blog…I thought it was odd as well
So there isn’t a way to do something like…
http://www.eaglerockfinancial.net/blog/* redirects to
http://blog.eaglerockfinancial.net/financial/blog/*I was hoping but didn’t know the syntax or how to set that up in .htaccess
Len
October 23, 2014 at 6:37 am #186900lprintzParticipantI just found this in a forum…this may be what I’m looking for but just need help on exactly how to set up in .htaccess:
“To use wildcards, put an asterisk after the folder name that you want to redirect.
Request: /old-folder/*
Destination: http://domain.com/redirect-everything-here/
”Whatcha think?
October 23, 2014 at 7:17 am #186905__Participantmod_rewrite is based on regular expressions, not shell pattern matching. “
*
” is a quantifier that means “zero or more” —so “/*
” means “match zero or more slashes.” It would match “/”, “//”, “//////////”, etc., or even “”.You would need to explain the relationships between the two URL formats more clearly, but assuming they are consistent, you could do something like
RewriteRule ^financial/blog/(.*)$ http://blog.eaglerockfinancial.net/financial/$1 [NC,R=301]
October 23, 2014 at 8:11 am #186916lprintzParticipantSorry for the confusion…notice that ‘blog/article-name’ is the same…just the first part of the URL changed. That’s why I was looking for some sort of ‘wildcard’ solution
Old – http://www.eaglerockfinancial.net/blog/financial-life-track-divorce/
New – http://blog.eaglerockfinancial.net/financial/blog/financial-life-track-divorceOctober 23, 2014 at 4:21 pm #186966__ParticipantAhh — yeah, your examples have been a bit inconsistent. It’s not a big thing to change. Again, there’s no “wildcard” in regex. You can do
.*
(as I did above), which means “zero or more of any character”.** except a newline, but that isn’t particularly important with URLs.
But, let me ask you this: do you want to redirect every URL? or only the blog entries? From your description, I would assume the latter.
And I would like to echo chrisburton’s confusion over the repetitiveness of new URL structure. Have you thought about fixing it?
October 24, 2014 at 5:15 am #186975lprintzParticipantHowdy!
Sorry for the confusion
I only want to redirect the blog entries so only the first part of the URL is changing which definitely needs to include /blog/
I agree with the bad URL structure of the new blog but, as I responded to Chris, this was done by a 3rd party (Hubspot) so I don’t have any control over it
Sooooo….can this be done? If so, could you shoot me the way I should set up in .htaccess?
Again, thanks so much for your response!
Len
October 24, 2014 at 3:40 pm #187013__ParticipantSooooo….can this be done? If so, could you shoot me the way I should set up in .htaccess?
Are you asking me to do it for you? If so, we should talk price. Or, do you want to figure out how to do it yourself? I’d be happy to help you learn if you come across something you can’t solve on your own.
If you want to learn, the example I posted above is a good place for you to start. You should also look at the mod_rewrite page in the Apache Manual. And there are lots of beginner tutorials around the web. If you have questions, please ask.
I agree with the bad URL structure …this was done by a 3rd party (Hubspot) so I don’t have any control over it
What I meant to ask was if you were interested in rewriting the new URLs also, so they could be more “friendly.”
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.