migrating from httpd 2.2 to httpd 2.4. mod rewrite returns eror 404

406 views Asked by At

Good afternoon, good evening, good morning or good nigt. I have a problem that I can't solve for a couple of days. I'm migrating from httpd 2.2 to httpd 2.4. And it seams that mod rewrite doesn't work. But may be I'm wrong and that is I'm working not well enough.

I'm using fedora 21. Migrating from another server. I installed mariadb httpd using yum. disabled selinux

chnged the the original httpd.conf to this:

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>

There will be a couple of sites, but at first I need to migrate at least one. My .htaccess file:

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>

So when i go to http://inyure.ua The mod rewrite changes the url to http://inyure.ua/ua but then apache gives an error 404.

If I changing the name of .htaccess file to another and add a string to main config

AccessFileNAme /var/www/html/config

Mod rewrite gives me "ua/" three times

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

and apache gives an error 404.

I tried to move everything from .htaccess to main config to VirtualHost directive.

Because I've red about a bug here | and here | and here

But then i am getting "ua/" three times and an err404 again.

Can anyone help me pleas :) Best regards.

1

There are 1 answers

0
Tyhovsky Pavel Boguslav On

I was so blind

code scrollbar on this site helped me to see :)

Changed httpd.conf:

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