从httpd 2.2迁移到httpd 2.4。 mod rewrite返回eror 404

时间:2015-06-09 17:49:51

标签: apache mod-rewrite apache2.4

下午好,晚上好,早上好,或者好。 我有一个问题,我几天都无法解决。 我从httpd 2.2迁移到httpd 2.4。并且它的接缝修改重写不起作用。但可能是我错了,那就是我的工作不够好。

我正在使用fedora 21.从另一台服务器迁移。 我用yum安装了mariadb httpd。 禁用selinux

将原来的httpd.conf改为:

LoadModule usertrack_module modules/mod_usertrack.so
LoadModule speling_module modules/mod_speling.so
LoadModule file_cache_module modules/mod_file_cache.so

Include conf.modules.d/*.conf
Include conf.d/*.conf

ServerName inyure.ua 
ServerTokens OS
ServerRoot "/etc/httpd"
Listen 80
Timeout 120
KeepAlive On
User apache
Group apache
RewriteEngine On
ServerAdmin root@localhost
DocumentRoot "/var/www"
AddDefaultCharset UTF-8
EnableSendfile on
ErrorLog "logs/error_log"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>
<Directory /var/www/html    >
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>


LogLevel warn

Alias /error/ "/var/www/error/"

<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>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<IfModule mime_module>

    TypesConfig /etc/mime.types

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

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

<IfModule mod_negotiation.c>
<IfModule mod_include.c>
    <Directory "/var/www/error">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en es de fr
        ForceLanguagePriority Prefer Fallback
    </Directory>
</IfModule>
</IfModule>

<Files ".ht*">
    Require all granted
</Files>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog /var/www/html/error.log
    CustomLog /var/www/html/access.log combined

    <Directory />

         #Options Indexes FollowSymLinks
         AllowOverride All
         Require all granted



</Directory>

</VirtualHost>

会有几个网站,但起初我需要迁移至少一个。 我的.htaccess文件:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?inyure.kiev.ua
RewriteRule (.*) http://inyure.ua/ua/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?inyure.computers.net.ua
RewriteRule (.*) http://inyure.ua/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?shop.inyure.kiev.ua
RewriteRule (.*) http://inyure.ua/ua/ [R=301,L]

RewriteRule ^modules/users/hybridauth/$ - [L]
RewriteRule ^admin/* - [L]

RewriteRule ^([\w]+)/news/seminar-new/?$  /$1/news/seminar/?%{QUERY_STRING} [R=301,L]

RewriteRule ^([\w]+)/([\w\d_-]+)$  /$1/$2/?%{QUERY_STRING} [R=301,L]
RewriteRule ^([\w]+)/([\w\d_-]+)/$ /index.php?xlang=$1&type=$2&%{QUERY_STRING} [L]

RewriteRule ^([\w]+)/([\w\d_-]+)/([\w\d,=;_-]+)$  /$1/$2/$3/?%{QUERY_STRING} [R=301,L]
RewriteRule ^([\w]+)/([\w\d_-]+)/([\w\d,=;_-]+)/$ /index.php?xlang=$1&type=$2&child=$3&%{QUERY_STRING} [L]

RewriteRule ^([\w]+)/([\w\d_-]+)/([\w\d,=;_-]+)/([\w\d,=;_-]+)$  /$1/$2/$3/$4/?%{QUERY_STRING} [R=301,L]
RewriteRule ^([\w]+)/([\w\d_-]+)/([\w\d,=;_-]+)/([\w\d,=;_-]+)/$ /index.php?xlang=$1&type=$2&child=$3&param1=$4&%{QUERY_STRING} [L]

RewriteRule ^([\w]+)/([\w\d_-]+)/([\w\d,=;_-]+)/([\w\d,=;_-]+)/([\w\d,=;_-]+)$  /$1/$2/$3/$4/$5/?%{QUERY_STRING} [R=301,L]
RewriteRule ^([\w]+)/([\w\d_-]+)/([\w\d,=;_-]+)/([\w\d,=;_-]+)/([\w\d,=;_-]+)/$ /index.php?xlang=$1&type=$2&child=$3&param1=$4&param2=$5&%{QUERY_STRING} [L]

RewriteRule ^([\w]+)$ /$1/?%{QUERY_STRING} [R=301,L]
RewriteRule ^([\w]+)/$ /index.php?xlang=$1&%{QUERY_STRING} [L]

RewriteRule ^$ /index.php?%{QUERY_STRING} [L]

php_flag magic_quotes_gpc Off
php_flag allow_url_include off


AddDefaultCharset utf-8

Order Deny,Allow

Allow from all

php_value upload_max_filesize 200M
php_value post_max_size 200M
php_value max_execution_time 200
php_value max_input_time 200


# Caching of images

<FilesMatch "\.(jpg|png|gif|js|css|ico|swf)$">
    Header set Expires "Thu, 31 Dec 2037 23:55:55 GMT"
    Header set Cache-Control "max-age=315360000"
   </FilesMatch>

所以当我去http://inyure.ua时 mod重写将网址更改为http://inyure.ua/ua 但是后来apache给出了错误404.

如果我将.htaccess文件的名称更改为另一个并将字符串添加到主配置

AccessFileNAme /var/www/html/config

Mod重写给了我&#34; ua /&#34;三次

http://inyure.ua/ua/ua/ua/

和apache给出错误404.

我尝试将所有内容从.htaccess移动到主配置到VirtualHost指令。

因为我已经了解了一个错误here | and here | and here

然后我得到&#34; ua /&#34;三次和一次err404。

任何人都可以帮我请求:)最好的问候。

1 个答案:

答案 0 :(得分:0)

我是如此盲目

此网站上的代码滚动条帮助我查看:)

更改了httpd.conf:

<Directory /var/www/html    >
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>