0

Due to the vagaries of my WP installation, I used to have permalinks in the following format:

OLD FORMAT: http://mysite.org/index.php/%year%/%monthnum%/%day%/%postname%/

at the time, "index.php" was necessary to make stuff work. My WordPress .htaccess file was standard.

Recently, my hosting company migrated me to another server. Now the old format does not work. A different permalink format, without the "index.php" does work:

NEW FORMAT: http://mysite.org/%year%/%month%/%daynum%/%postname%/

Since there are many legacy links in my blog and on third party sites in the old format, I would like to maintain the old format. I tried inserting redirect and rewrite rules into the .htaccess file, but to no avail.

Thanks!

1 Answer 1

1

You can add this rule:

RewriteRule ^index.php/(.*)/?$ /$1/ [R=301,L]

Above the WordPress rules:

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

And it will send a 301 permanent redirect from your old styling URL's to the new ones.

Given that your .htaccess have the basic WordPress rules it would look like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php/(.*)/?$ /$1/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Sign up to request clarification or add additional context in comments.

1 Comment

Ha! This is even better than the solution I was thinking of. Now the legacy URLs get converted, but I can make new posts with a URL without "index.php", chaining myself to the legacy format forever. Many thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.