0

I am trying to strip incoming page requests to 25 characters after the year/month structure of the URL on my Wordpress server. Reason is, there are a number of external 404 links that I would like to resolve. The Wordpress server is able to guess what the page should be. So far, I have the following Rewrite Rules configured:

RewriteRule     "/\d{4}/\d{2}/.{25}\.html$" - [L]
RewriteRule     "/(\d{4})/(\d{2})/(.{25}).+\.html$" "/$1/$2/$3.html" [L]

I have these rules set in sites-available/site-name.

The rewrite log shows the URL as being re-written, however the link still results in a 404 and the rewritten URL is not passed to the browser.

Am I going about this the wrong way?

Kris
  • 1
  • 1
  • I think you want to change `.{25}` to `.{,25}` as the former will only match 25 characters (ie. if only 24 characters were present, it would not match) – Cameron Kerr Jun 01 '15 at 03:39
  • I would also suggest that you want to 301 redirect such requests. This will let search engines update their indices. – Cameron Kerr Jun 01 '15 at 03:40
  • I have made the following rule changes with still no luck. `RewriteRule /[0-9]{4}\/[0-9]{1,2}\/.{1,25}\.html$ - [L]` `RewriteRule ^/([0-9]{4})\/([0-9]{1,2})\/(.{25}).*\.html$ /$1/$2/$3.html [R=302,L]` – Kris Jun 01 '15 at 04:10

0 Answers0