1

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
</Proxy>

ServerRoot "/home/bitnami/stack/apache2"

Listen 80

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

<IfModule !php5_module>
    Define USE_PHP_FPM
</IfModule>

<IfModule unixd_module>
User daemon
Group daemon

</IfModule>

ServerAdmin [email protected]

ServerName localhost:80

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

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

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

<Files ".ht* .php">
    Require all denied
</Files>
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
    </IfModule>

    CustomLog "logs/access_log" common

</IfModule>

<IfModule alias_module>

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

</IfModule>

<IfModule cgid_module>
</IfModule>

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

<IfModule mime_module>
    TypesConfig conf/mime.types

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

</IfModule>

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

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

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>
<IfVersion >= 2.3>
    Require all denied
</IfVersion>

</Files>

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"
</IfModule>

Include "conf/deflate.conf"
Include "/opt/bitnami/apache2/conf/bitnami/bitnami.conf"
Include "/opt/bitnami/apache2/conf/bitnami/httpd.conf"

2 Answers 2

0

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
</IfModule>

0

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.

Reference:

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

You must log in to answer this question.

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