Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a new server, which seems to almost be working. I've done my homework, but I seem to be stuck.

PHP works.

When I try to access the following URLs, which serve the same page correctly on the previous server, they each have a different response:

A. /input/ The requested URL /input.php/ was not found on this server.

B. /input A copy of input.php is downloaded through the browser.

C. /input.php Served correctly.

I realize that A and B is may be two separate but potentially related questions, so I will choose the answer that solves the issue with B.

My .htaccess file, which is the same as my other setup: Options +FollowSymLinks RewriteEngine on

# a request for /file/ will return /file.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L,QSA]

My httpd.conf:

ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
    Require all granted
    Allow from all

ServerRoot "/home/bitnami/stack/apache2"

Listen 80

LoadModule authn_file_module modules/
LoadModule authn_core_module modules/
LoadModule authz_host_module modules/
LoadModule authz_groupfile_module modules/
LoadModule authz_user_module modules/
LoadModule authz_core_module modules/
LoadModule access_compat_module modules/
LoadModule auth_basic_module modules/
LoadModule socache_shmcb_module modules/
LoadModule reqtimeout_module modules/
LoadModule filter_module modules/
LoadModule deflate_module modules/
LoadModule mime_module modules/
LoadModule log_config_module modules/
LoadModule env_module modules/
LoadModule headers_module modules/
LoadModule setenvif_module modules/
LoadModule version_module modules/
LoadModule proxy_module modules/
LoadModule proxy_connect_module modules/
LoadModule proxy_ftp_module modules/
LoadModule proxy_http_module modules/
LoadModule proxy_fcgi_module modules/
LoadModule proxy_scgi_module modules/
LoadModule proxy_wstunnel_module modules/
LoadModule proxy_ajp_module modules/
LoadModule proxy_balancer_module modules/
LoadModule proxy_express_module modules/
LoadModule slotmem_shm_module modules/
LoadModule ssl_module modules/
LoadModule lbmethod_byrequests_module modules/
LoadModule lbmethod_bytraffic_module modules/
LoadModule lbmethod_bybusyness_module modules/
LoadModule mpm_event_module modules/
LoadModule unixd_module modules/
LoadModule status_module modules/
LoadModule autoindex_module modules/
LoadModule negotiation_module modules/
LoadModule dir_module modules/
LoadModule alias_module modules/
LoadModule rewrite_module modules/

<IfModule !php5_module>
    Define USE_PHP_FPM

<IfModule unixd_module>
User daemon
Group daemon



ServerName localhost:80

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
    Allow from all

DocumentRoot "/home/bitnami/htdocs"
<Directory "/home/bitnami/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
    Allow from all

<IfModule dir_module>
    DirectoryIndex index.html index.php

<Files ".ht* .php">
    Require all denied
ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    CustomLog "logs/access_log" common


<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/opt/bitnami/apache2/cgi-bin/"


<IfModule cgid_module>

<Directory "/opt/bitnami/apache2/cgi-bin">
    AllowOverride None
    Options None
    Require all granted

<IfModule mime_module>
    TypesConfig conf/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz


<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

Include conf/pagespeed.conf
Include conf/pagespeed_libraries.conf

AddType application/x-httpd-php .php .phtml

<Files ".user.ini">

<IfVersion < 2.3 >
    Order allow,deny
    Deny from all
<IfVersion >= 2.3>
    Require all denied


ServerSignature Off
ServerTokens Prod

Include "/opt/bitnami/apache2/conf/ssi.conf"
AddType application/x-httpd-php .php

<IfModule php5_module>
        PHPIniDir "/opt/bitnami/php/etc"

Include "conf/deflate.conf"
Include "/opt/bitnami/apache2/conf/bitnami/bitnami.conf"
Include "/opt/bitnami/apache2/conf/bitnami/httpd.conf"
share|improve this question

I guess the line:

AddType application/x-httpd-php .php .phtml

has to be WITHIN <IfModule mime_module> and </IfModule>

So it perhaps should has to be:

<IfModule mime_module>
        TypesConfig conf/mime.types
        AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
        AddType application/x-httpd-php .php .phtml

share|improve this answer

If I understand You correctly, You want /input/, /input and /input.php all be redirected to /input.php. If that is the case, then the .htaccess file should look like that:

RewriteEngine On
RewriteRule ^([a-z\-\_]+)$ /$1.php [L]
RewriteRule ^([a-z\-\_]+)/$ /$1.php [L]

This will redirect all letters, "-" and "_" to the same name but with .php addition.


Apache mod_rewrite Introduction (see "Figure 1" in "Regex Back-Reference Availability" section)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .