• A year ago I have changed permalinks on my site and place this redirect into htacces file like this:

    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ https://mysite.com/$4

    It was always working, but now, for some reason the file is always being removed on its own.

    This is my htaccess file and place where I usually had it:

    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 week"
    ExpiresByType image/jpeg "access plus 1 week"
    ExpiresByType image/gif "access plus 1 week"
    ExpiresByType image/png "access plus 1 week"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/pdf "access plus 1 week"
    ExpiresByType text/x-javascript "access plus 1 week"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 week"
    ExpiresDefault "access plus 2 days"
    </IfModule>
    ## EXPIRES CACHING ##
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ https://mysite.com/$4
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
Viewing 4 replies - 1 through 4 (of 4 total)
  • WordPress controls all lines between the # BEGIN WordPress and # END WordPress lines. WP will reset these lines any time the permalinks are changed or saved. Create your own section and your changes should not be replaced.

    Thread Starter jronder

    (@villas-diani)

    Thank you so much vtxyzzy,what do you mean Create your own section? How:-( where should I put that redirect. I am also not sure if it should be there still:-( I am sorry if my questions are stupid, but I am very new to this.

    Thank you very much,

    All the best
    July

    I am not an htaccess expert, but I think you can add these lines to .htaccess BEFORE # BEGIN WordPress:

    # BEGIN Custom
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ https://mysite.com/$4
    </IfModule>
    # END Custom
    Thread Starter jronder

    (@villas-diani)

    Thank you so much! I am going to try, hopefully this time it will stay there.
    Thank you so much and good day,

    all, the best
    July

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect remove itself from httacces file’ is closed to new replies.