Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I asked the question in WPSE before, but the answer I got so far is a complicated one. I'm actually looking for a .htaccess way. Here's what the scenario is:

My blog archive URLs were like:

http://example.com/2014/03

I changed my site's permalink from /%postname%/ to /%postid%/%postname%/, and using Redirection plugin, I set a redirection like: redirection 1

and it's working. But the problem occurs in the archive URLs. The new archive URL generated with a /date/ basename before the dates, like:

http://example.com/date/2014/03

I'm trying to use the same Redirection plugin to redirect the URL, but failed: redirection 2

I then tried writing .htaccess on my own (with no .htaccess writing experience) with:

Redirect permanent http://example.com/([0-9]+)/([0-9]+) http://example.com/date/([0-9]+)/([0-9]+)

with the help of htaccess editor and this blog. But failed too.

How can I let my blog not to get 404 on such archive URL? I'm afraid, I'm dumb with rewrite rule till now. :(

UPDATE

Here's how my .htaccess file just now:

# 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

And with Liam Sorsby's answer, I tried pasting the code

RewriteEngine on
RewriteRule ^([0-9]+)/([0-9]+)$ /date/$1/$2 [R=301,L]

just below the # END WordPress once, and then tried again just before # END WordPress. But both time failed.

share|improve this question
    
This question appears to be off-topic because it is incomplete. Please ask your entire question here. Do not link to another website with the question text. –  John Conde Apr 7 at 14:34
    
@JohnConde: Edited the question with thanks. :) –  Mayeenul Islam Apr 7 at 14:47

1 Answer 1

I've had a quick test and this should do the trick:

RewriteEngine on
RewriteRule ^([0-9]+)/([0-9]+)$ /date/$1/$2 [R=301,L]

You may also need to exclude this from the redirect to the index.php page by adding

RewriteCond %{REQUEST_URI} !^/(date) [NC]

so it should look like this

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

RewriteRule ^([0-9]+)/([0-9]+)$ /date/$1/$2 [R=301,L]
</IfModule>
# END WordPress
share|improve this answer
    
Not working. I tried example.com/2010/10 on the browser after writing my .htaccess, it's taking me to 404 page. –  Mayeenul Islam Apr 7 at 14:42
    
what is the resulting web page? –  Liam Sorsby Apr 7 at 14:43
    
I mentioned that, it's taking me to 404 page. The URL is NOT changing to example.com/date/2010/10 –  Mayeenul Islam Apr 7 at 14:45
    
i can't see any issue with the above rule and i have tested it using htaccess.madewithlove.be can you post where you have put the code above so i can take a look? Just a note, i'm try to help, you dont have to bold and capitalise –  Liam Sorsby Apr 7 at 14:49
    
Updated my question –  Mayeenul Islam Apr 7 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.