# Misconfigured .htaccess file on bluehost

**URL:** https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185
**Category:** Need Help
**Created:** [March 29, 2021, 11:23pm UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185 "2021-03-29T23:23:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![makamo66](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/makamo66/32/2156_2.png) [@makamo66](https://discourse.cakephp.org/u/makamo66)
#### Post date: [March 29, 2021, 11:23pm UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/1 "2021-03-29T23:23:28Z")

</div>

Internal Server Error  
The server encountered an internal error or misconfiguration and was unable to complete your request.

I followed the cookbook here:  
[https://book.cakephp.org/4/en/installation.html](https://book.cakephp.org/4/en/installation.html)

.htaccess in webroot:

```
<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /path/to/app
	RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

```

.htaccess in the root directory:

```
#not sure if this belongs in this file
#don't know what the path to mod_rewrite.so is
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^$ webroot/ [L]
   RewriteRule (.*) webroot/$1 [L]
</IfModule>

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

<Directory /home4/maureep0/public_html/mysitesfolder>
    Options FollowSymLinks
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>
```

---

<div class="post-metadata">

### Author: ![makamo66](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/makamo66/32/2156_2.png) [@makamo66](https://discourse.cakephp.org/u/makamo66)
#### Post date: [March 30, 2021, 12:42am UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/2 "2021-03-30T00:42:39Z")

</div>

I tried the online tester at [https://htaccess.madewithlove.be/](https://htaccess.madewithlove.be/) but it mostly returned: “This line is not supported by our tool.”

---

<div class="post-metadata">

### Author: ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)
#### Post date: [March 30, 2021, 1:56am UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/3 "2021-03-30T01:56:10Z")

</div>

Ok so, you don’t need that \<Directory\> stuff, that’s for a completely different file (httpd.conf) in case the original rewrites don’t take.

The .htaccess in _root_ really only exists for your protection, in case you accidently publish that instead of your webroot folder. When you set your public folder (for what is seen when they go to the site) that is webroot which you “share”.

Try this in your _root_ folder: -

```auto
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ webroot/ [L]
    RewriteRule (.*) webroot/$1 [L]
</IfModule>

```

which is just saying if somehow a browser got to this folder then throw them to the public one. Its poor security as they could manually type in full paths if they knew it was a CakePHP app and perhaps find something they shouldn’t.

.htaccess is eye-of-the-beholder (although correct me if I’m wrong) in that its relative to what the client browser sees - written from their perspective.

Again that stuff RewriteBase shouldn’t be needed - only if you got a funky setup. So your .htaccess in your _webroot_ need only be: -

```auto
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]
</IfModule>

```

Which is just a bit of routing protection for dead links.

If I haven’t got it right then you’ll need an expert 🙂

---

<div class="post-metadata">

### Author: ![dirk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dirk/32/2174_2.png) [@dirk](https://discourse.cakephp.org/u/dirk)
#### Post date: [March 30, 2021, 12:26pm UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/4 "2021-03-30T12:26:30Z")

</div>

for example here are my .htaccess files from project running on shared webspace at ionos:  
in root directory:

> ```
> <IfModule mod_rewrite.c>
> RewriteEngine on
> 
> #the next 2 lines are only for forwarding to https
> RewriteCond %{SERVER_Port} !=443
> RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
> # end of forwarding
> 
> RewriteBase /
> RewriteRule ^(\.well-known/.*)$ $1 [L]
> RewriteRule ^$ webroot/ [L]
> RewriteRule (.*) webroot/$1 [L]
> </IfModule>
> 
> ```

in folder webroot :

> ```
> <IfModule mod_rewrite.c>
> RewriteEngine on
> RewriteBase /
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^ index.php [L]
> </IfModule>
> 
> ```

---

<div class="post-metadata">

### Author: ![makamo66](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/makamo66/32/2156_2.png) [@makamo66](https://discourse.cakephp.org/u/makamo66)
#### Post date: [March 30, 2021, 12:45pm UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/5 "2021-03-30T12:45:29Z")

</div>

I used dirk’s code and it worked. Thanks, dirk.

---

<div class="post-metadata">

### Author: ![makamo66](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/makamo66/32/2156_2.png) [@makamo66](https://discourse.cakephp.org/u/makamo66)
#### Post date: [March 30, 2021, 12:46pm UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/6 "2021-03-30T12:46:47Z")

</div>

Thanks, Jawfin for providing so much info

---

<div class="post-metadata">

### Author: ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)
#### Post date: [March 30, 2021, 1:15pm UTC](https://discourse.cakephp.org/t/misconfigured-htaccess-file-on-bluehost/9185/7 "2021-03-30T13:15:37Z")

</div>

Heh, no worries. I actually removed my https redirections in my post so as to not confuse, as there can be more work for that; getting a certificate etc. I also force redirect my website to https.

Glad you got it working 🙂
