1

I am migrating my site from Wordpress to Jekyll and I would like to keep the URLs working. My idea was to use a .htaccess file for this and to place it in the root of the site. But unfortunately after trying several tutorials and generates it doesn't seem to work.

The old URLs have the following format

http://example.com/index.php/2016/05/07/title-of-the-blog-post/

The new URLs have this format:

http://example.com/2016/05/07/title-of-the-blog-post.html

Among others I've tried this example which looks good to me, but it actually casues all pages on my site to display an error message :)

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^index.php.*$ http://example.com/ [R=301,L]

I think that should take all URLs that start with example.com/index.php and make them start with example.com/, but apparently that is not the case.

1 Answer 1

1

To redirect

  • http://example.com/index.php/2016/05/07/title-of-the-blog-post/

to

  • http://example.com/2016/05/07/title-of-the-blog-post.html

you can use the following rule :

RewriteEngine on
RewriteRule ^index\.php/(.+)$ http://example.com/$1.html [NE,L,R]

or alternatively you can use mod_alias like that:

RedirectMatch 301 ^/index\.php/(.+)$ http://example.com/$1.html
Sign up to request clarification or add additional context in comments.

1 Comment

That one was very close! I needed to add one extra slash to make it work. It seems so simple after I saw your example :). RewriteRule ^index\.php/(.+)/$ http://example.com/$1.html [NE,L,R]

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.