Ankündigung

Einklappen
Keine Ankündigung bisher.

Apache2 and PHP, react on suffix "php.htm& amp;a mp

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Apache2 and PHP, react on suffix "php.htm& amp;a mp

    Hi,

    is there a possability to configure Apache2 (v2.0.49) together with
    PHP (v4.3.7, installed as a module), so that URLs ending on
    ".php" AND on ".php.htm"
    are processed by PHP, but URLs ending only on
    ".htm"
    are not processed by PHP?

    I tried the following in "httpd.conf":
    LoadModule php4_module [...]php4apache2.dll
    AddType application/x-httpd-php php.htm php
    but this does not work (just reacts on "php" but not on "php.htm").
    If I remove "htm" from the "mime.types" in the line
    text/html html htm
    it works, but then all URLs ending on "htm" are processed by PHP.

    And if I use a "RedirectMatch" directive like
    RedirectMatch (.*)\.php\.htm$ $1.php
    I need to have a second file with the suffix ".php" next to the one
    with the suffix ".php.htm".

    Any ideas?

    Thanks in advance..


  • #2
    Re: Apache2 and PHP, react on suffix "php.htm"

    Zitat von Vampire
    Hi,

    is there a possability to configure Apache2 (v2.0.49) together with
    PHP (v4.3.7, installed as a module), so that URLs ending on
    ".php" AND on ".php.htm"
    are processed by PHP, but URLs ending only on
    ".htm"
    are not processed by PHP?
    First thing, the URL is not of interesst to Apache. The URL is always just a mapping, that gets evaluated to a concrete File.
    That mostly the URL maps to a identical File, does not render this wrong (simply because there is at least the document_root, that gets evaltuated).

    The File-Extension is it, wich provides the Mapping to PHP in our case (MimeMagic could have the potential .. but i'm not that sure about it ..).
    Since a file-Extenstion is the string after the last dot, no chance in using two dots as Extension (even adding quotation won't help).

    Zitat von Vampire
    And if I use a "RedirectMatch" directive like
    RedirectMatch (.*)\.php\.htm$ $1.php
    I need to have a second file with the suffix ".php" next to the one
    with the suffix ".php.htm".
    Why must it be .php.htm?
    How about .phtm(l)

    A RewriteRule should suit you better. Because it does noch redirect you to the *.php, but just internally uses the *.php for precession the Request, but leaves the Browser with it's URL on *.php.htm ...

    Kommentar


    • #3
      Re: Apache2 and PHP, react on suffix "php.htm"

      Zitat von Guradia
      Why must it be .php.htm?
      How about .phtm(l)

      A RewriteRule should suit you better. Because it does noch redirect you to the *.php, but just internally uses the *.php for precession the Request, but leaves the Browser with it's URL on *.php.htm ...
      A little complicated..
      I'm using a CMS and manage content which is mixed by JSP- and PHP-code.
      The JSP-code comes from templates with the suffix ".jsp" (including a navigation etc).
      The PHP-code comes from objects with the suffix ".php.php".
      When template and object are merged, the suffix is ".php.jsp".
      Now the JSP-code gets statified (which means it is called once per URL request, the result is HTML-code (generated by a JSP-engine) with the PHP-code still inside and written to the final file).
      The suffix for statified JSPs is configured to ".htm", so that the statified PHP objects with a JSP template get the suffix ".php.htm".
      This way, I can differentiate between "normal" HTML files which should not be processed by the PHP module (performance issues, of cource it would work if the PHP module would handle the suffix ".htm") and HTML files which still have PHP-code inside.
      If I configured the suffix of statified JSPs to ".phtm", also all JSPs without PHP-code inside would get this suffix and the problem would be the same.

      Well, I think I have to
      a) Rename all files with suffix ".php.htm" to ".php" and alter all links in the content of other files from ".php.htm" to ".php"
      b) Copy/rename each ".php.htm" file to ".php" and use the "RedirectMatch (.*)\.php\.htm$ $1.php" directive
      in order to solve this issue..

      Kommentar


      • #4
        I hope you have a zentral Method for generating the Filenames.
        Within it you can check for '.php.php' in the (or one of the) Source-File(s). And alter the Save-Path to just .php, rather than .php.htm

        This, and forcing the CMS to reevaluate all Pages, should save you from, renaming by hand or a cron'ed Batch ...



        btw: Apache is able to detect multiple Extetnsions .. but will use the most right (directonally) one, when Types are concurrent.

        Kommentar

        Lädt...
        X