Iddo
Iddo

Reputation: 123

index.php in Wordpress URLs

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!

Upvotes: 0

Views: 548

Answers (1)

Prix
Prix

Reputation: 19528

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>

Upvotes: 1

Related Questions