Why doesn't my .htaccess file redirect my old WordPress permalink structure?

by rohrl77   Last Updated October 17, 2019 14:04 PM - source

About 9 months ago i changed my permalink structure in WordPress from the domain.com/year/month/article-name format to the domain.com/article-name one.

I hired someone to do the rewrite rules for me. The person seemed to have done a good job, as all links i tested redirected as expected.

1 month ago I moved my website to a new server. The friend who moved it, first copied my website to his own server, then installed it on a droplet on digitalocean. In this process the individual also made changes to the .htaccess file.

I seem to now have lost all my redirects from the previous change.

I have tried the following:

  1. Based on this article I attempted to make a change to the line RewriteBase / in the WordPress section to RewriteBase /web/. This broke my website, so i changed it back.
  2. Moving the WordPress section to the beginning of the file. It seems to do nothing.

How can I reimplement the former redirect... I unfortunately lost all earlier versions of the file.

# RewriteRule ^9671126861/(.*)$ guzzle-downslope.php [QSA,L]
<ifmodule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 7200 seconds"
  ExpiresByType image/x-icon "access plus 8640000 seconds"
  ExpiresByType image/gif "access plus 8640000 seconds"
  ExpiresByType image/jpeg "access plus 86400000 seconds"
  ExpiresByType image/jpg "access plus 86400000 seconds"
  ExpiresByType image/png "access plus 86400000 seconds"
  ExpiresByType text/css "access plus 8640000 seconds"
  ExpiresByType text/javascript "access plus 864000000 seconds"
  ExpiresByType application/x-javascript "access plus 864000000 seconds"
  ExpiresByType application/javascript "access plus 864000000 seconds"
  ExpiresByType font/ttf "access plus 8640000 seconds"
  ExpiresByType font/otf "access plus 8640000 seconds"
  ExpiresByType application/vnd.ms-fontobject "access plus 8640000 seconds"
  ExpiresByType application/x-woff "access plus 8640000 seconds"
  ExpiresByType application/x-font-ttf "access plus 864000000 seconds"  
  ExpiresByType application/x-font-woff "access plus 8640000 seconds"    
  ExpiresByType application/vnd.ms-fontobject "access plus 864000000 seconds"  
  ExpiresByType image/svg+xml "access plus 8640000 seconds"
  ExpiresByType image/vnd.microsoft.icon "access plus 8640000 seconds"  
</ifmodule>

# BEGIN WPSuperCache
# END WPSuperCache

# BEGIN optimizeMember GZIP exclusions
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{QUERY_STRING} (^|\?|&)optimizemember_file_download\=.+
    RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END optimizeMember GZIP exclusions

# BEGIN rlrssslReallySimpleSSL rsssl_version[3.2.3]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
# 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

php_value upload_max_filesize 25MB
php_value post_max_size 27MB
php_value memory_limit 30MB


Answers 1


OK. So after having spelled out the question and posted it, I finally found the solution in this blog post.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Additional rewrite rules go here
    **RewriteRule ^[0-9]{4}/[0-9]{2}/(.*)$ /$1 [R=301,L]**

    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

# END WordPress
rohrl77
rohrl77
October 17, 2019 13:40 PM

Related Questions


WordPress custom permalink

Updated July 17, 2017 21:04 PM

htaccess rewrite incoming links to new one

Updated February 29, 2016 03:01 AM