【问题标题】:After upgrade .htaccess does not work升级后.htaccess 不起作用
【发布时间】:2017-07-06 16:42:36
【问题描述】:

我的提供商 1 天前更新服务器(我不知道以前的版本)。 现在重写不起作用索引包括,执行和重定向: http://testdomena.com -> http://testdomena.com/index/index(正确) 但在那之后我看到了:

Not Found

The requested URL /index/index was not found on this server.

Apache/2.4.7 (Ubuntu) Server at testdomena.com Port 80

地址正确,更新前一切正常。

现在我的服务器看起来像这样:

  • Ubuntu 14.04.5 LTS(GNU/Linux 3.13.0-108-generic x86_64)
  • 服务器版本:Apache/2.4.7 (Ubuntu)
  • PHP 5.5.9-1

apache2.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<directory /var/www/>
    options indexes followsymlinks
    allowoverride none
    require all granted
</directory>

<directory /home/>
    options indexes followsymlinks
    allowoverride none
    require all granted
</directory>

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

testdomena.conf

<VirtualHost *:80>
        ServerName testdomena.com
        DocumentRoot /home/web/testdomena
        <Directory /home/web/testdomena/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
</VirtualHost>

.htaccess

SetEnv APPLICATION_ENV "production"

Options +FollowSymlinks -Indexes

RewriteEngine On
RewriteBase /

# No www in url
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ http://testdomena.com/$1 [R=301,L]

# Maintain page
RewriteCond %{DOCUMENT_ROOT}/index.php !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* maintain.php [PT,L]

# Files and dirs are not welcome
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(media|styles)/?

# And we don't want to check www subdomain
RewriteCond %{HTTP_HOST} !=www.testdomena.com
RewriteRule .* index.php [PT,L]

来自 phpinfo() 的部分

Loaded Modules
core mod_somod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_filter mod_headers mod_mime prefork mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_socache_shmcb mod_ssl mod_status

【问题讨论】:

标签: php apache .htaccess ubuntu mod-rewrite


【解决方案1】:

我找到了答案: https://serverfault.com/questions/372733/apache-file-negotiation-failed

TypesConfig /etc/mime.types 问题是 /etc/mime.types 文件被更新替换了,在替换的文件中,PHP 部分被注释掉了。搜索时发现:

#application/x-httpd-php                        phtml pht php
#application/x-httpd-php-source                 phps
#application/x-httpd-php3                       php3
#application/x-httpd-php3-preprocessed          php3p
#application/x-httpd-php4                       php4
#application/x-httpd-php5                       php5

我必须从包含 php 相关内容的每一行中删除 #,然后保存并重新启动 Apache Web 服务器。无需修改 mime.conf 文件即可解决问题

【讨论】:

    猜你喜欢
    • 2013-11-29
    • 2015-12-08
    • 2015-12-10
    • 2015-02-13
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    • 2013-05-19
    • 2012-05-26
    相关资源
    最近更新 更多