Redirect old articles to new articles .htaccess - apache

This is a pretty specific question, so no answer on Stack or Google could help me.
Recently I've moved my blog from www.example.com to www.example.com/blog.
On www.example.com I have a landing page, so I need it to be working as well.
I would like to redirect all www.example.com/YYYY/MM/DD/article-name to www.example.com/blog/YYYY/MM/DD/article-name, but at the same time to keep www.example.com intact.
Thank you in advance for your help.

Try this code :)
RedirectMatch "^/(\d){4}/(\d){2}/(\d){2}/(.+)" "^/blog/$1/$2/$3/$4"
If this doesn't do the job, the following line definitely will:
RedirectMatch "^/(\d)+/(\d)+/(\d)+/(.+)" "^/blog/$1/$2/$3/$4"

Solved with Regular Expression inspired from the above answer from Hello Fishy(Thank you)
RedirectMatch ^/(\d*)/(\d*)/(\d*)/([A-Za-z0-9-]*)/ /blog/$1/$2/$3/$4

Related

RedirectMatch 301 ^/cgi- http://www.example.com/cgi/ubb/Ultimate.cgi doesn't work

I have successfully corrected all of the Google crawler errors except /cgi-
I don't know much but it seems strange to me. (www.somedomain.com is not my real site)
http://www.somedomain.com/cgi-xxx
redirects OK
but
http://www.somedomain.com/cgi-
doesn't ????
This is the .htaccess
RedirectMatch 301 ^/cgi- http://www.somedomain.com/cgi/ubb/Ultimate.cgi
Please help... this has been an open question for 13 days.

Apache rewrite url help, add string in the middle of the url

I need some help with my apache rewrites since I am quite bad at it.
I want to make an apache rewrite rule where I can rewrite links from my old site format to the new one.
http://foo.bar/old/$1 to http://foo.bar/new/$1. This should also work when old is a random string or empty.
Thanks in advance.
If anyone has the same issue as i did, i found the solution:
RedirectMatch 301 ^/([-0-9a-zA-Z])/(.)$ http://foo.bar/new/$2

redirect only domain.com to domain.com/subfolder/index.php not domain/whatever

If user request existing php code, which I placed right in the root:
domain.com/images/pic1.jpg
domain.com/anyphp.php
domain.com/someapp/somecode.php
domain.com/anything.someExt
etc
don't do anything,leave as it, they are working good.
But if he simply enter domain.com -> send him to domain.com/myNewApp/index.php, which is my cool new app. Don't rewrite the URL to domain.com/index.php because it is for my existing app.
I expect the answer may be super simple but I am just giving up trying
DirectoryIndex oxwall/index.php
Simple but it works
Do you have access to the Apache conf file? If so:
RewriteEngine on
RedirectMatch ^/(.*)$ http://example.com/myNewApp/index.php
Should work.
Edit: This rewrite won't work. I never used the regex-capture. And I misread what you wanted. It looks like you found an answer, but this should still work if you change the regex to:
RewriteEngine on
RedirectMatch ^/$ http://example.com/myNewApp/index.php
Check out this page for more re-writey goodness:
http://httpd.apache.org/docs/current/rewrite/remapping.html

Please help me redirect old url to new url using htaccess

I have some old urls from our old site as follows:
http://www.example.com/archives/2006/08/test.html
I want all my urls as shown above, starting with www.example.com/archives/* to point to www.example.com/gossip
Can anyone please give me the right htaccess code to do the same? Thanks a lot!
Kip
This will do what I think you're asking for:
RewriteEngine On
RewriteRule ^/archives/.*$ /gossip [R,L]

RedirectMatch query string issue

I am moving content on a previous website where 2 copies of the site were made to translate it so that i only have one remaining.
To provide fallback access, i wrote this rewritematch rule :
RedirectMatch 301 /(en|fr)/(.+)\.php\??(.+)? /$2.php?locale=$1&$3
But it doesn't seem to be working.
If i do the following instead, everything works fine but i lose the query string passed in the original link which i really want.
RedirectMatch 301 /(en|fr)/(.+)\.php /$2.php?locale=$1&$3
Is there something i am doing wrong? Or are query strings not supported? (I checked but there seems to be no limitations on the apache docs).
Thanks in advance for your help!
try
RedirectMatch 301 /(en|fr)/(.+)(\.php\?)?(.+)?