# Updating .htaccess with occ not working

**URL:** <https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244>\
**Category:** ℹ️ Support\
**Created:** [January 31, 2017, 3:10am UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244 "2017-01-31T03:10:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cthulhu](https://help.nextcloud.com/user_avatar/help.nextcloud.com/cthulhu/32/2720_2.png) [@cthulhu](https://help.nextcloud.com/u/cthulhu)\
**Post date:** [January 31, 2017, 3:10am UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/1 "2017-01-31T03:10:08Z")

</div>

I migrated my owncloud to Nextcloud,  
like the manual says here: [https://nextcloud.com/migration/](https://nextcloud.com/migration/)  
All permissions are correct.

On my owncloud installation i got the index.php hiding because of the rewritebase and the .htaccess.  
When i ran  
`sudo -u www-data php occ maintenance:update:htaccess`  
with nextcloud, my .htaccess did not change.

I deleted my .htacess and ran the command again,  
the only result was a .htaccess file with these lines:  
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

```
ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php

```

Looks like the occ command does not update/create the htaccess correct.

I updated the .htaccess manually with the code from my OC installation  
and it worked.

I already tried it with permission 777 on .htacces but nothing changed.

* * *

Nextcloud version _(eg, 10.0.2)_: 11  
Operating system and version _(eg, Ubuntu 16.04)_: 16.04  
Apache or nginx version _(eg, Apache 2.4.25)_: 2.4.18  
PHP version _(eg, 5.6)_: 7.0

---

<div class="post-metadata">

**Author:** ![Sanook](https://help.nextcloud.com/user_avatar/help.nextcloud.com/sanook/32/13847_2.png) [@Sanook](https://help.nextcloud.com/u/Sanook)\
**Post date:** [January 31, 2017, 3:18am UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/2 "2017-01-31T03:18:37Z")

</div>

> [@cthulhu](#):
>
> sudo -u www-data php occ maintenance:update:htaccess

As far as i know, this will update only the section for rewrite index.php

---

<div class="post-metadata">

**Author:** ![Ark74](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ark74/32/2071_2.png) [@Ark74](https://help.nextcloud.com/u/Ark74)\
**Post date:** [January 31, 2017, 3:24am UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/3 "2017-01-31T03:24:08Z")

</div>

You should have something like this:  
[http://pastebin.com/WSgbBe6R](http://pastebin.com/WSgbBe6R)

See [here](https://help.nextcloud.com/t/rewritebase-not-in-effect/1531/23?u=ark74).

---

<div class="post-metadata">

**Author:** ![Hollerauer](https://help.nextcloud.com/user_avatar/help.nextcloud.com/hollerauer/32/8935_2.png) [@Hollerauer](https://help.nextcloud.com/u/Hollerauer)\
**Post date:** [January 31, 2017, 4:46am UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/4 "2017-01-31T04:46:02Z")

</div>

> [@cthulhu](#):
>
> I already tried it with permission 777 on .htacces but nothing changed.

Are you using SELinux?  
If so you have to do additional [SELinux configuration](https://docs.nextcloud.com/server/11/admin_manual/installation/selinux_configuration.html).

---

<div class="post-metadata">

**Author:** ![cthulhu](https://help.nextcloud.com/user_avatar/help.nextcloud.com/cthulhu/32/2720_2.png) [@cthulhu](https://help.nextcloud.com/u/cthulhu)\
**Post date:** [January 31, 2017, 3:45pm UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/5 "2017-01-31T15:45:01Z")

</div>

> [@Sanook](#):
>
> As far as i know, this will update only the section for rewrite index.php

But it does not, just the htaccess like it was before, no rewrite rule or sth added after the command.

> [@Ark74](#):
>
> You should have something like this:

That was in there, so the initial file was correct but no update was done.

> [@Hollerauer](#):
>
> Are you using SELinux?

Nope, using Ubuntu Server.

---

<div class="post-metadata">

**Author:** ![Ark74](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ark74/32/2071_2.png) [@Ark74](https://help.nextcloud.com/u/Ark74)\
**Post date:** [January 31, 2017, 6:34pm UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/6 "2017-01-31T18:34:39Z")

</div>

> [@cthulhu](#):
>
> That was in there, so the initial file was correct but no update was done

The last link I sent explained why.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 2, 2024, 12:38pm UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/7 "2024-12-02T12:38:51Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 1:03pm UTC](https://help.nextcloud.com/t/updating-htaccess-with-occ-not-working/8244/8 "2024-12-04T13:03:04Z")

</div>


