Назад | Перейти на главную страницу

Перенаправления Apache не работают. Я получаю ошибку 404

Я пытаюсь настроить перенаправление, но у меня проблемы. Перенаправление HTTP на HTTPS действительно работает, но попытка создания RESTful API - нет. Любые идеи были бы хорошы. Спасибо.

<VirtualHost *:80 *:443>
    <Directory /var/www/example.com/public_html>
        #Options +FollowSymLinks
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog /var/www/example.com/error.log
    CustomLog /var/www/example.com/requests.log combined

    RewriteEngine On #only turn on once

    #force https
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    <Directory "/var/www/example.com/public_html">
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-s
        RewriteRule ^(.*)$ /api/index.php?rquest=$1 [QSA,NC,L]

        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]

        RewriteCond %{REQUEST_FILENAME} -s
        RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]
        </IfModule>

    </Directory>


</VirtualHost>

Изменить: я переписал второй раздел каталога, чтобы он выглядел так:

   <Directory "/var/www/example.com/public_html">
        <IfModule mod_rewrite.c>
        RewriteEngine On

        #force https
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-s
        RewriteRule ^(.*)$ /api/index.php?rquest=$1 [QSA,NC,L]

        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]

        RewriteCond %{REQUEST_FILENAME} -s
        RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]
        </IfModule>

    </Directory>