Apache 2.4 上未找到 phpmyadmin 404

Apache 2.4 上未找到 phpmyadmin 404

我似乎无法让 phpmyadmin 与我当前的 Apache/2.4.7 (Ubuntu:Trusty) 设置正常工作。

phpmyadmin 安装正确,并且我已将/etc/phpmyadmin/apache.conf文件包含在其中VirtualHost,但导航到https://www.domain.com/phpmyadminpanel/,出现 404 响应,而网站的其余部分则正常运行。

我不完全确定是什么原因造成的,我是否忽略了某些明显的东西?

/etc/phpmyadmin/apache.conf

# phpMyAdmin default Apache configuration

Alias /phpmyadminpanel /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_admin_flag allow_url_fopen Off
        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/
    </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
</Directory>

/etc/apache2/sites-enabled/domain.com.conf

# Redirect HTTP traffic to HTTPS
<VirtualHost *:80>

    ServerName  domain.com
    ServerAlias  www.domain.com
    Redirect / https://www.domain.com/za

</VirtualHost>

# Redirect HTTP traffic to HTTPS
<VirtualHost *:80>

    ServerName  sub.domain.com
    Redirect / https://sub.domain.com/na

</VirtualHost>

# HTTPS configuration
<IfModule mod_ssl.c>
    <VirtualHost _default_:443>

        ServerName domain.com
        ServerAlias www.domain.com
        ServerAlias sub.domain.com

        ServerAdmin [email protected]
        DocumentRoot /var/www/html
        DirectoryIndex index.php

        # Logging and such
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # Enable mod_ssl and mod_rewrite
        RewriteEngine on
        SSLEngine on

        RewriteCond %{HTTP_HOST} ^sub.domain.com$
        RewriteCond %{REQUEST_URI} ^/?$
        RewriteRule ^/?(.*)$ /na/ [R=301]

        RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www.domain.com$
        RewriteCond %{REQUEST_URI} ^/?$
        RewriteRule ^/?(.*)$ https://www.domain.com/za/ [R=301]

        RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www.domain.com$
        RewriteCond %{REQUEST_URI} ^/na/.*$
        RewriteRule ^/na/(.*)$ https://www.domain.com/za/$1 [R=301]

        RewriteCond %{HTTP_HOST} ^sub.domain.com$
        RewriteCond %{REQUEST_URI} ^/za/.*$
        RewriteRule ^/za/(.*)$ /na/$1 [R=301]

        RewriteCond %{REQUEST_URI} ^.*\.php$
        RewriteRule ^/(.*)\.php$ /$1 [R=301,QSA]

        RewriteCond %{REQUEST_URI} !^/za/admn/.*
        RewriteCond %{REQUEST_URI} !^/za/ea/.*
        RewriteCond %{REQUEST_URI} ^/.*/index$
        RewriteRule ^/(.*)/index$ /$1 [R=301,QSA]

        RewriteCond %{HTTP_HOST} ^sub.domain.com$
        RewriteCond %{REQUEST_URI} ^/na/.*$
        RewriteRule ^/na/(.*)$ /za/$1

        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
        RewriteRule ^/(.*)$ /$1.php [L,QSA]

        # SSL Stuff goes here
        SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
        </Directory>
        <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>

        BrowserMatch "MSIE [2-6]" \
                       nokeepalive ssl-unclean-shutdown \
                       downgrade-1.0 force-response-1.0

        Include /etc/phpmyadmin/apache.conf

    </VirtualHost>
</IfModule>

答案1

在其他配置之后,您有 PHPMyAdmin 配置的包含,其中包括一个捕获全部重定向:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^/(.*)$ /$1.php [L,QSA]

因此,请将您的Include语句移至配置文件中的较早位置。

相关内容