首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.htaccess文件问题/无法编辑.htaccess

.htaccess文件问题/无法编辑.htaccess
EN

Stack Overflow用户
提问于 2016-08-19 15:03:46
回答 1查看 2.7K关注 0票数 1

我使用GoDaddy主机提供商,当我在cpanel中编辑.htaccess时,它会生效,但几个小时(有时是几天)后,.htaccess就会回到默认状态。我所有的更改都消失了。

我编辑过的.htaccess文件:

代码语言:javascript
复制
# 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)在浏览器栏中,我的网站总是没有www 2)我的网站的IP不重定向到我的网站。

但这里的主要问题是,为什么在我编辑了.htaccess之后,它会变成默认设置?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-19 15:12:21

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

代码语言:javascript
复制
<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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39032962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档