Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
How to enable mod_redirect in htaccess over HTTP/2

I've modified my Debian 9 installation (Apache 2.4.25) to allow HTTP/2 support.

I've successfully checked it online, and the pages do serve, but the problem lies with the redirection performed in .htaccess to map for example site.com/index.php/brands/mybrand to a nice url (site.com/brands/mybrand). It simply does not happen. This is a Codeigniter setup.

  • The problematic steps seem to be when I disable the current modules (a2dismod php7.2 and mpm_prefork) and I enable a mpm module(a2enmod mpm_event, but I also tried mpm_worker) that supports HTTP/2.
  • At that point I get "file not found" (404 error)
  • By reverting those two steps I get back to normal (no HTTP/2 of course)

Is the mod_rewrite.c conditional below invalidated by loading the mpm_worker module? If so how do I replace it?

EDIT: a detailed Log show me this error: AH01071: Got error 'Primary script unknown\n', referer: https://sitename.com/brands/

My .htaccess (in the brands directory where index.php resides) which works fine with the previous configuration is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>
IndexOptions +Charset=UTF-8

My /etc/apache2/sites-enabled/default-ssl.conf relevant content includes:

<VirtualHost _default_:443>
         # even without enabling here h2c or h2 I get the error
         Protocols http/1.1
         <Directory "/var/www/html">
                 Options Indexes FollowSymLinks MultiViews
                 AllowOverride All
                 # since apache 2.4
                  Require all granted
         </Directory>

</VirtualHost>

Note: Other commands that I previously run to enable additional modules required are these ones below. I didn't have to touch anything of this to revert back to a working (non HTTP/2) configuration:

apt-get install php7.2-fpm
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm

Edit:

The problem was because of an internal redirect. It is fixed now.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You have not configured PHP-FPM correctly. Disable that php-fpm configuration by saying a2disconf php7.2-fpm. And add the following in the httpd.conf file, this should work:

<FilesMatch "\.php$">
SetHandler  "proxy:fcgi://localhost:9000"
</FilesMatch>
ProxyErrorOverride On

Restart Apache and PHP-FPM (PHP-FPM restart probably not required, but Apache must be restarted). Enable HTTP/2 now, it should work probably.

Edit

The OP had this problem from some redirect in the configuration.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!