.htaccess file issue / can't edit .htaccess


.htaccess file issue / can't edit .htaccess

我使用GoDaddy Hosting Provider,当我在cpanel中编辑。htaccess时,它生效,但几个小时(有时几天)后。htaccess又回到默认值。我的改动都没了。

My EDITED .htaccess文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{HTTP_HOST} ^xxx'.xxx'.xxx'.xx
RewriteCond %{HTTP_HOST} ^my-domain'.com
RewriteRule (.*) http://www.my-domain.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#Maintenance Mode
#RewriteCond %{REMOTE_ADDR} !^111'.111'.111'.11
#RewriteCond %{REQUEST_URI} !^/berightback'.html$
#RewriteRule ^(.*)$ http://my-domain.com/berightback.html [R=307,L]

ExpiresActive on
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
</IfModule>
# END WordPress

还发生了一些奇怪的事情:1)在浏览器栏我的网站总是没有www2)我的网站IP不能重定向到我的网站

但是这里的主要问题是为什么。htaccess在我编辑后变成默认设置?

谢谢!

这是你的wordpress安装。#Begin wordress#End Worpress标签内的任何内容都会被wordpress覆盖。你需要删除开始和结束注释之外的所有非wordpress规则。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Maintenance Mode
#RewriteCond %{REMOTE_ADDR} !^111'.111'.111'.11
#RewriteCond %{REQUEST_URI} !^/berightback'.html$
#RewriteRule ^(.*)$ http://my-domain.com/berightback.html [R=307,L]"
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{HTTP_HOST} ^xxx'.xxx'.xxx'.xx
RewriteCond %{HTTP_HOST} ^my-domain'.com
RewriteRule (.*) http://www.my-domain.com/$1 [R=301,L]
# BEGIN WordPress
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
ExpiresActive on
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month

特别是当您对永久链接进行更改时。你可以看到其他人也有同样的问题。https://wordpress.org/support/topic/htaccess-file-being-overwritten