htaccess – Incorrect route appended to URL when redirected from http to https

I have an OVH-hosted WordPress site and problems redirecting http to https. Keep feeding nicely Keep feeding nicely

however continues to lead,

I do not know where this extra www comes from.

My .htaccess looks like this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} (L,R=301)

www to not www with .htaccess


Did not you do it?

With CPM banner ads, CPM email advertising, and contextual CPC links, you can promote virtually anything. You can target relevant parts of the site and serve ads based on the user's geographic location, if you so choose.

Starts at just $ 1 per CPM or $ 0.10 per CPC.

How can I use the .htaccess file to redirect all web requests to a subfolder with SSL?

OK, I have a basic PHP website (not WordPress) that I've just moved from GoDaddy to Nixihost. By default, the root Web site is placed in the root Web folder / public_html. Instead, the root site should be stored in a subfolder of the root Web folder at /public_html/ com)

At GoDaddy I had the following .htaccess file in the file / public_html and it worked fine. Even all http requests have been rewritten as https requests:

# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} (L,R=301) 
# Change to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/ 
# Don't change the following two lines. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteRule ^(.*)$ /$1 
# Change to be your main domain again. 
# Change 'subdirectory' to be the directory you will use for your main domain 
# followed by / then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?$ 
RewriteRule ^(/)?$
rewriterule ^news$ "" (R=301,L) #57e44bbcecccd

But now that I move to Nixihost, I get when I visit

You don't have permission to access / on this server.
Server unable to read htaccess file, denying access to be safe

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

When I remove the .htaccess file, a directory listing of the / public_html folder appears, indicating that it is a .htaccess issue.

What should my correct .htaccess file be, or do I have my .htaccess file correctly and the problem lies with the Nixihost server?

htaccess – I can not run two or more URL rewrite rules at the same time


I tried to shorten the URL further, but I removed the .php file extension from the URLs by also rewriting the URL. I can not do both at the same time.

Remove the extensions and try shortening the link from{username}


   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^((^.)+)$ $1.php (NC)
   RewriteRule ^((a-zA-Z0-9-z)+)$ profile.php?id=$1 (NC)

Only the first thing I try, works, or removes the extension or profile.php? Id removed, not both.

Do you need advice on domain redirection (htaccess, DNS, registrar)?


have 2 domains and

I need to redirect to

Previous domain-level developer setup redirect to, but in this case, unfortunately returns 404 because b / c does not have an SSL setup.

My question is, how is it possible to set up the htaccess here so that it can redirect http to https without having to renew the SSL on the old domain (

Ps. What about DNS redirection?

Need help with URL redirection in .htaccess

I recently moved links from one directory to another. Instead of creating a Rewrite 301 for each link, I'd like to do a single rewrite, but I do not know how it works.

Example for old URLs:

/Catalog/flurosenia / hn_4zk / hn4zk130.htm
/Catalog/flurosenia / hn_4zk / hn4zkxcG.html

Example of NEW URLs:

/Catalog/lily1000125 / hn_5rp / hn5rp130.htm
/Catalog/lily1000125 / hn_5rp / hn5rpxcG.html

What I need is something (rewrite, redirect or whatever) that will change that RED Sections to BLUE sections

.htaccess – Index.php prompts you to download rather than run it

I am experiencing a problem in which I am trying to load my Drupal site, but instead of switching to the main page you will be prompted to download / save the file.

I know that my PHP is active and I can not figure out what this is about. I looked around while googling, but none of the suggestions helped. Has anyone else encountered this problem? I use Drupal 7.

Apache configuration file:

    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    TypesConfig conf/mime.types

    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #AddType application/x-gzip .tgz
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3

    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    # Filters allow you to process content before it is sent to the client.
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml

.htaccess file:

# Apache/PHP/Drupal settings:

# Protect files and directories from prying eyes.

  Order allow,deny

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php index.html index.htm

# Override PHP settings that cannot be changed at runtime. See
# sites/default/default.settings.php and drupal_environment_initialize() in
# includes/ for settings that can be changed at runtime.

# PHP 5, Apache 1 and 2.

  php_flag magic_quotes_gpc                 off
  php_flag magic_quotes_sybase              off
  php_flag register_globals                 off
  php_flag session.auto_start               off
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_flag mbstring.encoding_translation    off

# Requires mod_expires to be enabled.

  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off

# Various rewrite rules.

  RewriteEngine on

  # Set "protossl" to "s" if we were accessed via https://.  This is used later
  # if you enable "www." stripping or enforcement, in order to ensure that
  # you don't bounce between http and https.
  RewriteRule ^ - (E=protossl)
  RewriteCond %{HTTPS} on
  RewriteRule ^ - (E=protossl:s)

  # Make sure Authorization HTTP header is available to PHP
  # even when running as CGI or FastCGI.
  RewriteRule ^ - (E=HTTP_AUTHORIZATION:%{HTTP:Authorization})

  # Block access to "hidden" directories whose names begin with a period. This
  # includes directories used by version control systems such as Subversion or
  # Git to store control files. Files whose names begin with a period, as well
  # as the control files used by CVS, are protected by the FilesMatch directive
  # above.
  # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
  # not possible to block access to entire directories from .htaccess, because
  #  is not allowed here.
  # If you do not have mod_rewrite installed, you should remove these
  # directories from your webroot or otherwise protect them from being
  # downloaded.
  RewriteRule "(^|/)." - (F)

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  # To redirect all users to access the site WITH the 'www.' prefix,
  # ( will be redirected to
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} .
  # RewriteCond %{HTTP_HOST} !^www. (NC)
  # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} (L,R=301)
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # ( will be redirected to
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www.(.+)$ (NC)
  # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} (L,R=301)

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at uncomment and
  # modify the following line:
   RewriteBase /drupal
  # If your site is running in a VirtualDocumentRoot at,
  # uncomment the following line:
   RewriteBase /

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php (L)

  # Rules to correctly serve gzip compressed CSS and JS files.
  # Requires both mod_rewrite and mod_headers to be enabled.
    # Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}.gz -s
    RewriteRule ^(.*).css $1.css.gz (QSA)

    # Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}.gz -s
    RewriteRule ^(.*).js $1.js.gz (QSA)

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule .css.gz$ - (T=text/css,E=no-gzip:1)
    RewriteRule .js.gz$ - (T=text/javascript,E=no-gzip:1)

      # Serve correct encoding type.
      Header set Content-Encoding gzip
      # Force proxies to cache gzipped & non-gzipped css/js files separately.
      Header append Vary Accept-Encoding

# Add headers to all responses.

  # Disable content sniffing, since it's an attack vector.
  Header always set X-Content-Type-Options nosniff

.htaccess Apache Core: Error 20023 20024

Apache 2.4 default settings, OS 7
Without .htaccess the site works fine. URL string contains localized characters. I'll create a .htaccess file strictly following instructions to create a short URL. and I have some errors loading the page:

(20023)The given path was above the root path: AH00127: Cannot map GET /%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0 HTTP/1.1 to file
(20023)The given path was above the root path: AH00127: Cannot map GET /favicon.ico HTTP/1.1 to file, referer:


RewriteEngine On
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php (L)

I could not find a clear answer or understand something. First, it is not clear why such a simple rule, which I have taken from a few instructions, does not work? Why does internal forwarding to index.php not work? How do you repair?
And second, why does not RewriteRuke work with localized, masked pages? (Bug 20024) Can somehow be fixed?

.htaccess – Docker httpd & htaccess – Password file could not be opened

I have one mistake that I can not fix despite my recent research.

Folder structure:

-rw-r--r-- 1 root root   105 Aug  8 15:58 Dockerfile
-rw-r--r-- 1 root root 21371 Aug  8 16:05 my-httpd.conf
drwxr-xr-x 2 root root  4096 Aug  8 15:37 www

1 – I create an image of Apache with a simple dockerfile


FROM httpd:2.4
WORKDIR /usr/local/apache2/htdocs
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf


docker build -t apache .

2 – I start a container with the new image


docker run -v /MY_PATH/www/:/usr/local/apache2/htdocs/ -dit --name apache -p 80:80 apache

3 – I want to protect access to the www folder with htaccess

Folder structure:

-rwxr-xr-x 1 root root  116 Aug  8 15:37 .htaccess
-rw-r--r-- 1 root root   46 Aug  8 15:34 .htpasswd
-rwxrwxrwx 1 root root  169 Aug  7 10:52 index.html
-rw-r--r-- 1 root root  354 Aug  7 10:56 master.css
-rw-r--r-- 1 root root   26 Aug  7 10:57 robots.txt


AuthType Basic
AuthName "Restricted Area"
AuthUserFile /MY_PATH/www/.htpasswd
Require valid-user

4 – I'm trying to access index.html in my browser

The connection window is displayed. I enter my username and password.

Then I have one 500 Internal server error

5 – The logs indicated that the password file could not be opened.

When I review the Apache container logs, I have the following:

(Fri Aug 09 07:19:58.458778 2019) (authn_file:error) (pid 7:tid 140331369154304) (2)No such file or directory: (client AH01620: Could not open password file: /MY_PATH/www/.htpasswd - user (09/Aug/2019:07:19:58 +0000) "GET / HTTP/1.1" 500 528
(Fri Aug 09 07:19:58.534805 2019) (authn_file:error) (pid 7:tid 140331135788800) (2)No such file or directory: (client AH01620: Could not open password file: /MY_PATH/www/.htpasswd, referer:

6 – I need your help 🙂

I searched Google many times. I found only the following about "SELinux": Permission denied: Password file could not be opened.

I am not sure if this is the case when using Docker.

So if someone can help me, it would be great! 🙂