.htaccess

.htaccess is removed automatically after creating it in htdocs i have tried lots of time. even tried in filezilla upload after uploading within a second it got removed. :roll_eyes: :roll_eyes: why it is removed. i tried some rewrite rules it is deleting file. But in .htaccess if i paste Options +Indexes file is not removed. Is there any restrictions on using rewrite rules. Earlier i have opened a post on removing ?i=1 in url
I have tried rewrite rule and file got lost. right now there is no .htaccess in htdocs as it is removing automatically

it could be that your .htaccess file is too large, the size limit for .htaccess is 10KBytes max and anything larger will be automatically deleted

5 Likes

This .htaccess code might not work currently i have tried many times but i can’t create that file. While creating .htaccess file inside htdocs it is automatically removed after sometimes.

Hi saikub,

There are many factors to .htaccess file, in general it’s not a good practise to use .htaccess file unless absolutely necessary due to it could be ignored by server settings, or things like this happens.

A solution has been provided to you before:

In case you have additional directives in your .htaccess file, then it’s another question to evaluate the necessity of those directives and whether those can be achieved through other means.

Cheers!

4 Likes

2 posts were split to a new topic: React App not Working

I used only the code which a thread or post had i’ll show you

# Turn on Rewrite Engine
RewriteEngine On
# Deny URLs Not Composed of “a-zA-Z0-9.+/-?=&” characters
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&]+\ HTTP/ [NC]
RewriteRule .? - [F,NS,L]
# Force / Suffix
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ https://%{HTTP_HOST}/$1$2/ [L,R=301]
# Remove ?i=1
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
# Forward Documents to .html Internally
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ $1.html [L]
# Forward Documents to .php Internally
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
# Force https:// Prefix
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>
# Remove www. Prefix
RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{HTTPS}s ^on(s)|off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L]
# Remove .html Suffix
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1/ [R=301,L]
# Remove .php Suffix
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]

And i tried only ?i=1 rule, also deleted. Something like it is not accepting Rewrite rule.

Yes.

The reason behind not using that script is i can’t implement it in all files. like i might used different projects and some are html some are php and i can import that script with just a script tag with a line. but while i’m testing the project i can do that on everytime, and i posted this post to let know everyone that before time this was not happened all .htaccess file can be written and accepted but after new upgrades this was happening and i found this lately.

is it possible you could upload your .htaccess file to some file sharing (like google drive etc) and post the link here, I would like to try it on my hosting and see what happens !

1 Like

I already have share the code above and it was from the forums page only

# Turn on Rewrite Engine
RewriteEngine On
# Deny URLs Not Composed of “a-zA-Z0-9.+/-?=&” characters
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&]+\ HTTP/ [NC]
RewriteRule .? - [F,NS,L]
# Force / Suffix
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ https://%{HTTP_HOST}/$1$2/ [L,R=301]
# Remove ?i=1
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
# Forward Documents to .html Internally
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ $1.html [L]
# Forward Documents to .php Internally
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
# Force https:// Prefix
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>
# Remove www. Prefix
RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{HTTPS}s ^on(s)|off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L]
# Remove .html Suffix
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1/ [R=301,L]
# Remove .php Suffix
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]

You can add any one rule to all these rules. In my hosting it is deleting automatically.

It’s just a matter of whether you’re willing to change extension from html to php.

htaccess are not as convenient on free hosting as you might have realized by hitting the file size limit, not because of an update btw, this file size limit thing has been there all along…

Either you can try, but sometimes you gotta do what you gotta do.

1 Like

The file size limit is what you were saying but the file is just 2kb and it is less than the limit. And i’m talking about .htaccess file where when i’m pasting or writing some RewriteEngine rules and saving them. after some time it is removed or deleted automatically.

In this case, do you have any programming that dynamically interact with the .htaccess or potentially perform any writing to it?

If so, that might be the case.

Also since your account has been suspended, it’s more important to solve that issue first before pondering with this file just yet. If your account is permanently suspended, solving the .htaccess file alone won’t get it back online anyways.

3 Likes

Yes i don’t even know what is happening all problems are new to me and i don’t know how to solve. Just checked pasted rewriteengle rule file got removed. and worried about is .htaccess file are also banned in this hosting as i’m trying these many times. they shouldn’t flag this to.

How i can solve this issue. where do i can do that. can you help me

Follow up on the other topic

2 Likes

A post was merged into an existing topic: How to remove ?i=1

I tried uploading that .htaccess file to one of my own accounts and it was deleted ~10 seconds after uploading it. When I uploaded segments of the files, it also deleted them. It’s really strange, and I’m unable to pinpoint exactly what triggers the removal, because it doesn’t seem to be file sizes or specific lines.

7 Likes

magic !

2 Likes

I experimented and this is the problem

# Remove ?i=1
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]

which makes sense to be disabled

But it is not always deleted during the upload, but every second or third time…
Sometimes 5 times in a row.

@saikub try monstaFTP (online file manager from Client Area)
and create a new file → name it .htaccess and then paste your necessary code inside (save).
I don’t think it would have been deleted then. I didn’t wait longer than 10 min…maybe it will be deleted later but try it…if it remains then great.

7 Likes

I have tried already, actually most trials from that application it is deleting. and sorry for late replies.

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