1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Mod rewrite .php to .html

Discussion in 'Apache' started by -=adi=-, May 18, 2005.

  1. #1
    Hi.
    If someone can help me.

    I wish to use mod rewrite to change the urls from page.php in page.html (all the urls of the site)

    What should i write in .htacces ?

    Also if someone can provide me an exemple for a single page like: www. mysite.com/page.php to be rewrited as www. mysite.com/page.html.

    Thanks
     
    -=adi=-, May 18, 2005 IP
  2. iktorn

    iktorn Peon

    Messages:
    66
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^/]*)\.html$ $1.php?%{QUERY_STRING} [NC]
     
    iktorn, May 18, 2005 IP
  3. -=adi=-

    -=adi=- Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks.

    Can you also tell me what will be the Rewrite syntax for one single page ?

    I want to test it before. :)

    Thanks again.
     
    -=adi=-, May 18, 2005 IP
  4. samsam

    samsam Peon

    Messages:
    647
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Test it in a sub folder :)
     
    samsam, May 18, 2005 IP
  5. THT

    THT Peon

    Messages:
    686
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    is there any benefit to rewriting php extensions to htm?

    i mean with no qeurystring - just php->htm
     
    THT, May 18, 2005 IP
  6. -=adi=-

    -=adi=- Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for idea.
    I've tested it on subfolder and even on main .htaccess and it didn't worked. :confused:
     
    -=adi=-, May 18, 2005 IP
  7. -=adi=-

    -=adi=- Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I was thinking for a better SE friendly url's.
    I don't know if .php urls (without Ids) just normal .php like /page.php are indexed well or not.

    That's why i'm thinking about rewriting.

    I don't know how it works without query if you asked me.

    ***********************************************

    Edit later

    Finally i've managed to make the server handle .html as .php.
    I've tried for some time but didn't worked, and now...WOW

    I put " AddHandler application/x-httpd-php .php .html .htm " in .htaccess and now my page.html is parsed as a php one.

    :)
     
    -=adi=-, May 18, 2005 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Or do

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)\.html$ $1.php [L]

    and the actual files can be page.php
     
    Nintendo, May 18, 2005 IP
  9. chowzer

    chowzer Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Does anyone know how to do this for all the pages in a PHPNuke system? What settings can I use or is there a plug-in to change all php file names to html?

    Thanks in advance!
     
    chowzer, Oct 19, 2005 IP
  10. MKInfo

    MKInfo DP Guard Dog

    Messages:
    1,481
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    140
    #10
    Yes there is one that I have used and its good.Changes ALL to html..Its called Googletap and you can get it from nukecops:)
     
    MKInfo, Oct 19, 2005 IP
  11. primefalcon

    primefalcon Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Mod rewrite there are 2 reasons to use mod rewrite

    1. Better se results, a lot of search engines will turn tail if they see the ? after .php in urls, not sure why, but se's don't really like indexing dynamically generated pages.

    2. Security, what your site is coded in is irrelevant at best, and a security vulnerability at worst, if people know what language your site is coded in, they'll more easily be able to exploit any code vulnerabilities.
     
    primefalcon, Jan 28, 2008 IP
  12. becomeme

    becomeme Active Member

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #12
    how can I have this code

    RewriteBase /
    RewriteRule ^([^/]*)\.html$ $1.php?%{QUERY_STRING} [NC]

    also be applied to sub directory pages...I want to change those to html as well....
     
    becomeme, Oct 19, 2009 IP
  13. y2k2

    y2k2 Guest

    Messages:
    212
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    how to change hello-word to hello_world for all using .htacess
     
    y2k2, Feb 24, 2010 IP