vendredi 31 juillet 2015

redirecting an .htaccess with regular expression

There are SO many .htaccess redirect posts on here, but unfortunately none that match my situation that I can find, and I'm struggling with understanding regular expressions to make this work. My situation:

Rebuilt a real estate site on Wordpress. The site had been established for many years before, and therefor had a ton of Google-crawled property URLs. The new site uses a completely different permalink structure with brand new properties and google search console is coming up with tons of 404 errors.

Old structure: http://ift.tt/1M24PTt New structure: http://ift.tt/1I8mQv9

I'd like to be able to write a .htaccess redirect to point ALL URLs that start with /0000/00/00/whatever to the home page. I've done some research onregular expressions and I've found similar cases but none that I can make work for me. They seem to just be ignored.

Guide site that I used: http://ift.tt/1M24Q9H

My relevant .htaccess code:

# BEGIN custom rewrite rules
RewriteEngine On
RewriteRule ^[0-9]{4}/[0-9]{2}/[0-9]{2}/.*/$ http://ift.tt/1I8mQvd [R=301]
# END custom rewrite rules

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Basically my custom redirect is a result of hacking together multiple tutorials on regular expression to try to match the relevant "old" urls. Can someone help me figure this one out? Is my custom redirect in the wrong place? (does it need to be AFTER the wordpress redirect code)? Help would be appreciated!

Dan

Aucun commentaire:

Enregistrer un commentaire