It looks like my .htaccess file has disappeared

Website URL

https://judahrobinsonfoundation.com/

Error Message

404 Error on all but the home page.

Other Information

it looks like my .htaccess file has disappeared. Please could you restore it. I had added the lines to force HTTPS but when I saved the file it vanished. Now I’m getting 404 errors.

Due to this?

There is no backup on free hosting.

5 Likes

OK, so I can edit the .htaccess file using the supplied tools but this will result in it’s deletion without warning, breaking the site, and you cannot fix it because there’s no backup. That’s hardly helpful. For anyone who encounters this issue in future, the following is a .htaccess file which works. It’s not the same as the one that got away.

BEGIN WordPress

The directives (lines) between “BEGIN WordPress” and “END WordPress” are

dynamically generated, and should only be modified via WordPress filters.

Any changes to the directives between these markers will be overwritten.

RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

Secure log files

<filesmatch “log$”>
order allow,deny
deny from all

#Disable xmlrpc.php via the .htacess File

Order Allow,Deny
Deny from all

WP Defender - Prevent information disclosure

<FilesMatch “.(md|exe|sh|bak|inc|pot|po|mo|log|sql)$”>
Order allow,deny
Deny from all

Allow from all Allow from all

WP Defender - End

type or paste code here

bbcode broke that .htaccess file. Try this:

BEGIN WordPress

The directives (lines) between “BEGIN WordPress” and “END WordPress” are

dynamically generated, and should only be modified via WordPress filters.

Any changes to the directives between these markers will be overwritten.

RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

Secure log files

<filesmatch “log$”>
order allow,deny
deny from all

#Disable xmlrpc.php via the .htacess File

Order Allow,Deny
Deny from all

WP Defender - Prevent information disclosure

<FilesMatch “.(md|exe|sh|bak|inc|pot|po|mo|log|sql)$”>
Order allow,deny
Deny from all

Allow from all Allow from all

WP Defender - End

type or paste code here

I understand that this isn’t a fun surprise, but there isn’t really a way around it.

We can only check the size of the uploaded file after the upload is complete, which means it’s too late to refuse the upload. And by then, the old file is overwritten too.

A file which works for WordPress, yes, and should only ever be used for a WordPress site. And even then, this contains some unnecessary directives. If you just need a working WordPress .htaccess file, you could just use the official WordPress .htaccess code instead:

7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.