[英].htaccess file issue / can't edit .htaccess
我使用GoDaddy Hosting Provider,當我在cpanel中編輯.htaccess時,它生效,但是幾個小時后(有時是幾天),. htaccess恢復為默認設置。 我所有的更改都消失了。
我編輯的.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)在瀏覽器欄中,我的網站始終沒有www
2)我的網站的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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.