OK, I have a basic php website (non WordPress) that I just moved from GoDaddy to Nixihost. By default, the root website gets put in the root web folder /public_html - however instead I wanted the root website in a subfolder of the root web folder at /public_html/4efix.com (The website in question is my simple www.4efix.com)

At GoDaddy I had the following .htaccess file in the /public_html and it worked perfectly, it even rewrote all http requests to https ones:

# .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 example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?4efix.com$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/4efix.com/ 
# 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 ^(.*)$ /4efix.com/$1 
# Change example.com 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.)?4efix.com$ 
RewriteRule ^(/)?$ 4efix.com/index.php
rewriterule ^news$ "http\:\/\/eepurl\.com\/AjC-j" [R=301,L] #57e44bbcecccd

But now that I moved to Nixihost, when I visit www.4efix.com I get

You don't have permission to access /4efix.com/403.shtml 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 I get a directory listing of the /public_html folder, which seems to indicate it is a .htaccess issue.

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

3 Answers 3


Went through your site and it works perfectly, Usually when you change hosts, It takes some time to fully propagate, Perhaps that's what you experienced, Use other devices and probably incognito mode to try it again and it works fine.

There's no problem seen!

  • turns out the issue was permissions - thanks for double checking my .htaccess code for me. :)
    – Sindyr
    Commented Aug 19, 2019 at 2:31
  • 1
    @Sindyr "...permissions" - you should add that as an answer, explaining specifically what the problem was - as this could help other readers.
    – MrWhite
    Commented Aug 19, 2019 at 23:52

As already noted, there's nothing seriously wrong with your .htaccess file and your site does now work (a permissions issue?). However, there are a few issues / suggestions regarding your current directives:

  1. rewriterule ^news$ "http\:\/\/eepurl\.com\/AjC-j" [R=301,L] #57e44bbcecccd

    This last directive (an external redirect) is not doing anything. The earlier rewrite will catch the request and rewrite it to the subdirectory before this directive is processed, so it never matches. (Although this looks like a redirect-loop anyway?)

    Line-end comments (ie. #57e44bbcecccd) are not supported by Apache config files. This particular directive doesn't break, only because you have provided all arguments to the RewriteRule directive. Try the same thing on an earlier rewrite and you'll get a 500 Internal Server Error (due to invalid RewriteRule flags) - see #2.

    Colons, slashes and dots do not need to be backslash escaped in the RewriteRule substitution string as they carry no special meaning here (it is a string, not a _regex). (This is indicatory of having implemented a redirect through cPanel.)

  2. Missing L flags on the internal rewrite (RewriteRule) directives. They don't break because there is no conflict. However, without the L flag, processing is unnecessarily continuing through the file and each directive is being processed. For example:

    RewriteRule ^(.*)$ /4efix.com/$1 [L]
  3. Literal dots (.) in the regex need to be escaped. The dot is a special meta character in the regex (matching any character - except newlines), so needs to be backslash escaped to match a literal dot. ie. ^(www.)?4efix.com$ should be ^(www\.)?4efix\.com$. Strictly speaking, your regex are matching "too much" (which could be an issue if you had similarly named subdirectories or URLs).

  4. There's no canonical www redirection. ie. Both www.example.com and example.com are accessible. Either redirect non-www to www OR www to domain apex.

  5. The site is accessible through the "hidden" subdirectory. ie. https://example.com/example.com/ is accessible (and this would continue to propagate due to the use of relative URLs throughout your site). You could redirect these requests to the canonical (root) URL or see #6.

  6. You could configure this domain as an Addon domain in cPanel (which seems to be the control panel used by Nixihost) and point it directly to the appropriate subdirectory (ie. /example.com/). This would avoid having to implement any internal rewrites in .htaccess and would satisfy #5 without an additional redirect.

  • 1: that rewrite was part of some much earlier testing and needs to be removed 6: Nixihost requires that one domain be assigned as a root domain, else I would do that. The root domain cannot be an add-on 5: I wasn't aware of that - how do I redirect it to the canonical root? 4: why is this important? 2+3: Will look up and try to educate myself on the L flag and the escape needs. -Thanks for your detailed insight.
    – Sindyr
    Commented Aug 21, 2019 at 0:20

So for some reason I still do not fathom, the fix turned out to be altering the target directory's permission from 750 to 755. (The files within the directory did not have to have their permissions altered at all, just the folder containing the redirected site.)

That was the answer, discovered by the helpful folks at Nixihost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.