Static Html page in WP using mod_rewrite

Discussion in 'Apache' started by susan8051, May 27, 2008.

  1. #1
    Hi,
    I am trying to make static pages in wordpress for example i want to make a page www.mysite.com/about.html

    For this i created a page with title About and i tried to change the permalink of the page to about.html but they don't accept a dot..So is there any way in which i can create a page using the WP's page creator and add .html to the end of the pages permalink..( i don't want to upload any html pages and do the job)

    (i hope this is the right section for this question as it is related to mod_rewrite.. if it is not, mods please do move it..)
     
    susan8051, May 27, 2008 IP
  2. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i got that corrected using a wordpress plugin http://txfx.net/files/wordpress/periods-in-titles.phps

    now i still have another problem.. i have a file named news.php on my server. I want this page to be shown when somebody types in news.html(i am not looking for a redirect..).When user types in news.html the contents of news.php should be shown.. is that possible???

    (To Mods: Couldn't edit the previous post)
     
    susan8051, May 28, 2008 IP
  3. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes you can without redirect, use mod_rewrite for it too :)
    Use this on your .htaccess file:

    
    RewriteEngine on
    RewriteBase /
    RewriteRule ^news\.html$ /news\.php
    
    Code (markup):
    now if someone will enter news.html in url, it will display content of news.php :)

    Thanks :)
     
    nastynappy, May 28, 2008 IP
  4. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for the reply.i already have wordpress on my server's root folder and the present .htaccess file is


    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Code (markup):
    So how should i edit this for the same..
     
    susan8051, May 28, 2008 IP
  5. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    just write this at the end of .htaccess :

    RewriteEngine On
    RewriteRule ^news\.php$ news\.html

    Note : news.html must exist :)
     
    nastynappy, May 28, 2008 IP
  6. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks i hope you meant the reverse.. :)

    My new htaccess is

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    RewriteEngine On
    RewriteRule ^latest\.html$ /latest\.php
    Code (markup):
    But when i goto sherlynchopra.org/latest.html it does not show the same thing as when we goto sherlynchopra.org/latest.php
     
    susan8051, May 28, 2008 IP
  7. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #7
    do you have latest.html in your home directory ?
     
    nastynappy, May 28, 2008 IP
  8. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #8
    no i have latest.php in the home directory..
     
    susan8051, May 28, 2008 IP
  9. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #9
    okay try this one :

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^latest.html$ latest.php
    </IfModule>

    so that, your file looks like :

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^latest.html$ latest.php
    </IfModule>

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    it works perfectly, tested it myself on my own wordpress :)

    http://www.pegor.com/latest.html --> http://www.pegor.com/latest.php
     
    nastynappy, May 28, 2008 IP
    susan8051 likes this.
  10. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks a lot but still it has some problem...not working.. :(

    i used exactly the same thing in the .htaccess file according to your updated post.. but it shows a page not found...

    My htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^latest.html$ latest.php
    </IfModule>
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    Code (markup):
    but still i have some problems.. sherlynchopra.org/latest.html doesn't show the same thing as sherlynchopra.org/latest.php :(
     
    susan8051, May 28, 2008 IP
  11. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #11
    hmm.. but it is working with me wordpress :confused: you can see my example bro..
    can you give me temporary access to your wordpress directory ? I will try some changes in htacess and see if it works..
     
    nastynappy, May 29, 2008 IP
  12. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #12
    thanks for your efforts i have pmed you my ftp login details..
     
    susan8051, May 29, 2008 IP
  13. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #13
    your details arent working :) says file or folder not found, cannot connect

    Updated :

    Done, You didnt use my coded htaccess, you added a forward slash before the latest.php :) but its fixed now, and I am glad that it is working just the way you wanted it to work
     
    nastynappy, May 29, 2008 IP
  14. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #14
    thanks a lot.. Reps added.. it worked fine when i used a normal text file as latest.php but when i use an original php file( in this case i used wordpress's index.php file as latest.php) Now latest.php shows the latest wordpress posts(same as index.php shows) but latest.html shows a wordpress 404 page :(
     
    susan8051, May 29, 2008 IP