Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess don';php升级后无法工作_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess don';php升级后无法工作

.htaccess don';php升级后无法工作,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我昨天购买了一台PHP版本为5.3.3的虚拟专用服务器 然后我将我的php版本升级到5.4.22 现在htaccess无法正常工作。。它没有任何作用。 我尝试的是: 我在httpd.conf中这样做了 <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny

我昨天购买了一台PHP版本为5.3.3的虚拟专用服务器 然后我将我的php版本升级到5.4.22 现在htaccess无法正常工作。。它没有任何作用。 我尝试的是: 我在httpd.conf中这样做了

 <Directory />
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
 </Directory>

选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
但它不起作用,所以我在我的.htaccess中尝试了这个:

<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
SetHandler x-httpd-php54
</FilesMatch>

SetHandler x-httpd-php54
这也不管用。 如果我用
创建一个页面并检查加载的模块,我会看到mod_rewrite已加载

我的.htaccess

<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak)$">
Order Allow,Deny
Deny from all
</FilesMatch>

RewriteEngine on
RewriteRule ^d/(.*)$ delete.php?img=$1 [L]
RewriteRule ^i/(.*)$ i.php?img=$1 [L]
RewriteRule ^e/(.*)$ editor.php?img=$1 [L]
RewriteRule ^u/$ /u/index.php?img=$1
RewriteRule ^([a-zA-Z0-9]*)$ getimage.php?image=$1



RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.(gif|jpeg|png|bmp|jpg) http://(ip)/6j5o [NC,L]
ErrorDocument 400 http://(ip)/404.php
ErrorDocument 401 http://(ip)/404.php
ErrorDocument 403 http://(ip)/404.php
ErrorDocument 404 http://(ip)/404.php
ErrorDocument 500 http://(ip)/404.php

命令允许,拒绝
全盘否定
重新启动发动机
重写规则^d/(.*)$delete.php?img=$1[L]
重写规则^i/(*)$i.php?img=$1[L]
重写规则^e/(.*)$editor.php?img=$1[L]
重写规则^u/$/u/index.php?img=$1
重写规则^([a-zA-Z0-9]*)$getimage.php?image=$1
重写cond%{DOCUMENT\u ROOT}%{REQUEST\u URI}-F
重写规则\(gif | jpeg | png | bmp | jpg)http://(ip)/6j5o[NC,L]
ErrorDocument 400 http://(ip)/404.php
错误文档401 http://(ip)/404.php
错误文档403 http://(ip)/404.php
ErrorDocument 404 http://(ip)/404.php
ErrorDocument 500 http://(ip)/404.php

有什么想法吗?(我的服务器是Centos 6 64位)

您的Apache配置位于
/etc/httpd/conf/httpd.conf
。确保这一行没有被注释掉

LoadModule rewrite_module modules/mod_rewrite.so
现在,转到
/etc/httpd/conf.d
并查看站点的配置(我希望您已经在这里创建了自己的
sitename.conf
)。你应该有这样的东西(你的可能会有相当大的不同,这是从一个服务器托管一个网站)


DocumentRoot/var/www/html/mydir
服务器名my.domain.name
服务器别名my.domain.name
错误日志/mydomain
自定义日志/mydomain通用
通融
选项+FollowSymLinks

确保使用站点根目录的完整路径名。

您是否也升级了apache或仅升级了PHP?我遵循了本教程:有一次apache升级,我想我可能是错的,但您的目录“标记”中不应该包含绝对根目录的完整目录路径吗?例如
您应该查看
httpd.conf
中的
mod\u rewrite.so
并取消对行的注释…什么类型的Linux?(CentOS、Ubuntu等)。此外,如果正确加载PHP,则不需要
SetHandler
。正常的加载项httpd.conf看起来像
AddHandler php5 script.php
<VirtualHost *:80>
    DocumentRoot /var/www/html/mydir
    ServerName my.domain.name
        ServerAlias my.domain.name

    ErrorLog logs/mydomain
    CustomLog logs/mydomain common

    <Directory "/var/www/html/mydir">
        Allow from all
        Options +FollowSymLinks
    </Directory>
</VirtualHost>