【问题标题】:migrating from httpd 2.2 to httpd 2.4. mod rewrite returns eror 404从 httpd 2.2 迁移到 httpd 2.4。 mod_rewrite 返回错误 404
【发布时间】:2015-08-24 16:47:08
【问题描述】:

下午好,晚上好,早上好或晚安。 我有一个问题几天都解决不了。 我正在从 httpd 2.2 迁移到 httpd 2.4。而且它接缝 mod rewrite 不起作用。但可能是我错了,那就是我工作得不够好。

我正在使用 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重写将url更改为http://inyure.ua/ua 但随后 apache 给出错误 404。

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

AccessFileNAme /var/www/html/config

Mod rewrite 给了我三次“ua/”

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

而 apache 给出错误 404。

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

因为我对一个错误感到不满here | and here | and here

但后来我得到“ua/”三次,又得到一个 err404。

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

【问题讨论】:

    标签: apache mod-rewrite apache2.4


    【解决方案1】:

    我真是瞎了眼

    这个网站上的代码滚动条帮助我看到:)

    更改了 httpd.conf:

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

    【讨论】:

      猜你喜欢
      • 2018-12-15
      • 2016-07-03
      • 2018-06-27
      • 2011-04-13
      • 1970-01-01
      • 2014-04-11
      • 1970-01-01
      • 2019-05-16
      • 2011-06-16
      相关资源
      最近更新 更多