Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question mod_rewrite html to php

    I'm new at all this, and need a little help.

    My website has static html pages. I would like to add a feed from my blog to a few of those pages. I want to use a php script embedded in my html. If I change the page name from xxxx.html to xxxx.php the feed from my blog is included, but any link to that page is broken. I would like the server to process the php on my html page; I was hoping that I could use mod_rewrite in my .htaccess file to implement that. The GoDaddy (sorry, I told you I was new at this) documentation indicates that mod_rewrite is enabled on linux servers by default. I've been trying to figure this out all day, but can't seem to get it to work. It would be a big help if you could point me in the right direction.

    Mahalo

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    I want to use a php script embedded in my html. If I change the page name from xxxx.html to xxxx.php the feed from my blog is included, but any link to that page is broken.
    You could treat your html files like your php files by adding a rule in your htaccess file like,

    Code:
    AddHandler application/x-httpd-php .php .html
    Hope this would be useful to you.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    376
    Thanks
    0
    Thanked 25 Times in 25 Posts
    To do it with mod_rewrite, try
    Code:
    Options +FollowSymLinks
    
    # Make sure the .php file exists
    RewriteCond %{DOCUMENT_ROOT}/$1php -f
    RewriteRule ^(.+\.)html$ /$1php [QSA,L]

  • #4
    Registered User
    Join Date
    Jun 2010
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello.

    I had Apache server and changed to Lighttpd..
    I had this functions for mod_rewrite in Apache..
    so how can I change them and use them in lighttpd ?

    .htaccess
    Code:
    RewriteEngine On
    RewriteRule ^index\.html$ ./index.php?mdrw=on
    RewriteRule ^manual\.html$ ./index.php?action=manual&mdrw=on
    RewriteRule ^([0-9]+)_([0-9]+)_([-0-9]+)\.html$ ./index.php?action=vthread&forum=$1&topic=$2&page=$3&mdrw=on
    RewriteRule ^([0-9]+)_([-0-9]+)\.html$ ./index.php?action=vtopic&forum=$1&page=$2&mdrw=on
    is it possible?

  • #5
    New Coder
    Join Date
    Jul 2011
    Location
    Texas
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Ersa View Post
    Hello.

    I had Apache server and changed to Lighttpd..
    I had this functions for mod_rewrite in Apache..
    so how can I change them and use them in lighttpd ?

    .htaccess
    Code:
    RewriteEngine On
    RewriteRule ^index\.html$ ./index.php?mdrw=on
    RewriteRule ^manual\.html$ ./index.php?action=manual&mdrw=on
    RewriteRule ^([0-9]+)_([0-9]+)_([-0-9]+)\.html$ ./index.php?action=vthread&forum=$1&topic=$2&page=$3&mdrw=on
    RewriteRule ^([0-9]+)_([-0-9]+)\.html$ ./index.php?action=vtopic&forum=$1&page=$2&mdrw=on
    is it possible?
    My best recommendation would be that you review the lighttpd mod_rewrite documentation and visit the lighttpd Support Forums if you have questions specific to lighttpd which are not being answered to your satisfaction here on the CodingForums.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •