V
V
Vasily2017-01-18 13:11:33
Apache HTTP Server
Vasily, 2017-01-18 13:11:33

How to change the server header encoding when redirecting and return a 404 page without a redirect to https?

There is a virtual hosting on TimeWeb.
The htaccess file has a redirect from www to non-www, from http to https:

AddDefaultCharset UTF-8
  AddType 'text/html; charset=utf-8' .html .htm .shtml

  # Перенаправление с www   
  RewriteCond %{HTTP_HOST} ^www.specpst\.com$ [NC]
  RewriteRule ^(.*)$ https://specpst.com/$1 [R=301,L]
  
  # Перенаправление с http на https 
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  ...
  # Перенаправляем в файл обработки URL
  RewriteRule ^(.*)$ /template/urlrewrite.php [L,QSA]

Redirects work correctly, but in the server response headers they give:
Server: nginx /1.10.1
Content-Type: text/html; charset=iso-8859-1
...
Depending on certain conditions, the urlrewrite file will incude a 404 error page.
Question:
- How to change the encoding of the server response when redirecting from charset=iso-8859-1 to UTF-8 (I assume that in the nginx settings because htaccess seems to be responsible for Apache, which are not available to me)?;
- How to immediately give a 404 error page without a preliminary redirect from http to https for example?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question