Website Breaking Down After Refresh

news.cp3.ct.ws

My website seems to break down every single time I refresh, here is my .htaccess file:

Options +MultiViews +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteEngine On
RewriteRule ^index.html$ / [R=301,L]

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:CF-Visitor} !{"scheme":"https"}
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

does that change anything?

Your page loads fine for me

Assuming the error is with the JS file, which my browser is blocking due to security concerns. Whatever you have in there is triggering some system of mine, which means it could also be triggering something on your site.

3 Likes

I don’t have a js file

Also it’s when you refresh the page.

Make sure that the line RewriteEngine On is not repeated twice. In case the line already exists, simply copy the rest of the code without it.

6 Likes

Okay, I tried it but it didn’t work.

What did not work? Write clearly

4 Likes

Never mind, deleting the extra RewriteEngine fixed it.

Generally speaking, specifying RewriteEngine On when it was already defined erases any previously configured directives. But when specifying it multiple times in a single file, it’s a bit unclear as to which rules will applied and which are not.

So you should only have one RewriteEngine On in your .htaccess file, above all the rewrite rules. And if you specify .htaccess rules in a subdirectory and want the rules from the parent directory to apply too, you should leave it out entirely.

4 Likes

Since my website, news.cp3.ct.ws is another domain, do I need to have a .htaccess file in there or only in the main htdocs?

You can have however many you want. Each will override any related rules in any parent directory.

3 Likes

It depends on what you want to do.

The behavior of .htaccess files is that the server will look for .htaccess files in any directory in the path of the request it’s trying to execute.

That means that the .htaccess file in the root directory of your account will be applied to all websites, but the file in the directory example.com/htdocs will only be applied to the example.com website. It won’t apply to the website in the example.net/htdocs directory, because that’s a different path.

A website in the directory example.com/htdocs/blog/ will receive the rules in the .htaccess file in the root directory, the one in the example.com/htdocs/ and the example.com/htdocs/blog/ directories. If example.com and example.com/blog are different websites, then it makes sense to use RewriteEngine On in the blog directory to override any rules from the website of example.com.

If you have multiple domains/websites and they both need certain .htaccess rules, they will both need a .htaccess file.

6 Likes

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