SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for Htaccess

    Hello all,
    I want to use .htaccess.
    I have a file dir.php under www folder .I am using apache2.5.1.
    and in dir.php top,I have written AddType application/x-httpd-php .php .htm
    and when i call from localhost with dir.htm then the page is not found?
    Can u fix my problem?

    If I am wrong so plz u guide me how to do that.
    I am using Apache 2.5.1 and php 5.0.2 and install it in d drive.
    and in d drive there is www folder and dir.php file is under that directory.
    Thank you for looking my problem.
    -::Ujjwal::-
    Visit My Site

  2. #2
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump
    -::Ujjwal::-
    Visit My Site

  3. #3
    SitePoint Addict liquidautumn's Avatar
    Join Date
    Nov 2002
    Location
    Kharkov, Ukraine
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jbviously, there was no dir.htm
    Do you think AddType will redirect requests to *.htm => *.php?
    It will not.

  4. #4
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know that but in url
    http://localhost/dir.htm
    but it will works as dir.php and obviously it is saved in .php ext.
    -::Ujjwal::-
    Visit My Site

  5. #5
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You have to use mod_rewrite to accomplish that.

    Code:
    RewriteEngine On
    RewriteRule ^dir\.htm$   dir.php
    Edit:

    I now realized that I might have misunderstood your question.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  6. #6
    SitePoint Addict liquidautumn's Avatar
    Join Date
    Nov 2002
    Location
    Kharkov, Ukraine
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Directive "AddType application/x-httpd-php .php .htm" says apache to pass files with php and htm extention to PHP interpretator, nothing more.
    If there is no dir.htm - there is 404. As it supposed to be.

  7. #7
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got it.Thanks lilleman and liqidautumn.
    But If i create a file like dir.php under www folder and I want to call from browser like
    http://localhost/dir.htm.
    Then How Can i do it.and yes in that folder there is no such dir.htm.
    but I want to call dir.php but it shows in url that dir.htm.
    How Can I implement this things .Anybody plz guide me .

    I have got AddType application/x-httpd-php .php .htm
    from tutorial but there is not written where I should store it that's why I written on the head of dir.php and thought it will works but it not.
    I am waiting for u'r guide to implement it.
    -::Ujjwal::-
    Visit My Site

  8. #8
    SitePoint Addict liquidautumn's Avatar
    Join Date
    Nov 2002
    Location
    Kharkov, Ukraine
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if i got it right, your aim is rewring htm to php
    you may use the following

    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*)\.htm[l]?$ /$1\.php
    this will rewrite all htm and html to php, if such file not exist

    say, you have "foo.htm" and "bar.php" on your "host"
    then, if you'll type http://host/bar.htm it will be rewriten to bar.php, but http://host/foo.htm will not

    does it make any sense?

  9. #9
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by liquidautumn
    if i got it right, your aim is rewring htm to php
    you may use the following

    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*)\.htm[l]?$ /$1\.php
    this will rewrite all htm and html to php, if such file not exist

    say, you have "foo.htm" and "bar.php" on your "host"
    then, if you'll type http://host/bar.htm it will be rewriten to bar.php, but http://host/foo.htm will not

    does it make any sense?
    Sorry,
    Actually lilleman was right.
    Listen all,
    I have a file whose ext is .php(e.g dir.php) in www folder and i want to call it from url using extn .htm(e.g http://localhost/dir.htm).
    How Can I succedeed on that?
    -::Ujjwal::-
    Visit My Site

  10. #10
    SitePoint Addict liquidautumn's Avatar
    Join Date
    Nov 2002
    Location
    Kharkov, Ukraine
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    solution i'm offered could do the job
    you just need to pay a little attention to mod_rewrite manual and read directives, i've provided

  11. #11
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok.So I am using apache 2.5.1 server and win xp as os.
    My question is that from where I can modified mod rewrite engine on?
    Can u guide me.
    -::Ujjwal::-
    Visit My Site


Bookmarks

Posting Permissions

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