[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

.htaccess redirect to the wrong locations

I am using a redirect to redirect visitors of my old blog to my new blog
Redirect 301 /log/ http://jasperfrumau.com/

Open in new window


this redirect seems to go to http://jasperfrumau.com/log and gives a 404. How can I fix this asap?

FYI http://wwww.gateway2thailand.com/log did go to http://jasperfrumau.com
0
rhandalthor
Asked:
rhandalthor
  • 2
  • 2
3 Solutions
 
a1jCommented:

You can try redirecting using mod-rewrite.

RewriteRule ^(.*)$ http://jasperfrumau.com/ [R=301,L]
0
 
a1jCommented:
Err i meant RewriteRule ^(log.*)$ http://jasperfrumau.com/ [R=301,L]

Or you can use redirectMatch instead of redirect:
RedirectMatch 301 ^(/log.*)$ http://jasperfrumau.com/ 

But i think your problem is that you are specifying it in .htaccess which is relevant only for current directory - you need to specify it in apache config.
0
 
crazedsanityCommented:
@a1j: the .htaccess files are applied for the directory they're in and all subdirectories: http://httpd.apache.org/docs/1.3/howto/htaccess.html#how

I would suggest using RedirectMatch:
RedirectMatch    ^/log*    http://jasperfrumau.com/

Open in new window

0
 
rhandalthorAuthor Commented:
Seems like my redirect 301 is working after all. What is the benefit in using a RedirectMatch?
0
 
crazedsanityCommented:
RedirectMatch uses regular expressions, which is especially useful to redirect people to the proper blog entry (assuming the entries are the same or can be programatically matched).  For instance, if the old blog is "/log/first_entry" and the new one is "http://domain.com/blog/first_entry", you could use:
RedirectMatch    /log/(.*)    http://domain/com/blog/$1

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now