Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

We had an old site that had html pages in it. One of the pages in that site was linked to from many other sites.

Now we moved to a WordPress site, and we created a page with that name, but of course it doesn't have the ".html" extension, so links to that page lead to an empty page...

I saw a plugin that adds html extesnsions to all pages, but I don't want that - I have only one page to which I want to add .html.

What can I do to accomplish this?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

I would just add a rewrite rule to your .htaccess file of something like:

Redirect 301 /oldpage.html http://domain.com/newpage/

see: http://www.javascriptkit.com/howto/htaccess7.shtml

share|improve this answer
    
Aces method is the best way to do this, just include this line in your .htaccess file, the file can be found in your wordpress installation folder! –  Philip Nov 24 '11 at 17:08
    
Thank you, but it doesn't work :(. This is what I'm writing: Redirect 301 http://dev.linux.ort.org.il/ortnew/rights/rights.html http://dev.linux.ort.org.il/ortnew/about/. My .htaccess looks as follows: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /ortnew/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /ortnew/index.php [L] </IfModule> # END WordPress I'm putting the redirect as the last command before the end of ` </IfModule>`, but nothing happens –  Lea Cohen Nov 27 '11 at 7:35
    
I wouldn't put it within the ifModule section - try either putting it after the last line or just above #END Wordpress. Also, the location of the file/directory you want redirected should be relative to the root of your site ie starting with a / not an http... see the linked page. –  Aces Nov 27 '11 at 12:39
    
Thank you very much for replying! Would you mind helping me along, or should I ask these follow-up questions on serverfault? Because I moved it out of the ifModule section, and also uploaded it to production to see if maybe it will work on that server. I wrote the location as you told me: #Redirect 301 /rights/rights.html http://ort.org.il/right/rights/, but it still doesn't work... I must be doing something wrong, but I don't know what :( –  Lea Cohen Nov 28 '11 at 7:23
1  
The # at the front will stop the line from working.... –  Aces Nov 28 '11 at 13:41

You could add a rewrite rule to your theme that sends requests for page.html to the page itself. I'm not confident to supply code, but the rewrite documentation on this page is helpful. The last example there is the simplest illustration I've found of query rewriting.

It helps to use ugly permalinks while you're arranging it as you get to see what requests trigger what. If not, doing print_r($wp_query) will let you have the contents of the current query.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.