网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   WordPress (https://www.0058.net/forumdisplay.php?f=68)
-   -   解决wordpress自动修改htaccess的问题 (https://www.0058.net/showthread.php?t=5770)

Cimarron Hills 2016-06-10 08:36 AM

解决wordpress自动修改htaccess的问题
 
折腾wordpress时间不短了,并用htaccess进行了优化等大量的设置,有几次发现htaccess的内容会被无故恢复掉。今天终于发现了原因。
原来在wordpress后台个修改Permanant Link形式时(不改,打开保存也会一样)时会自动把htaccess重写。
当然它是以
# BEGIN WordPress 开头
# END WordPress 结束
所以,现在解决的办法也很简单,就是把自已增加的写在这个后台就行了。
我之前一直放在# END WordPress里面,难怪老被恢复掉。

Code:

# BEGIN WordPress

 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]

 # END WordPress

FileETag none


 AddOutputFilter DEFLATE html htm xml php css js



 Header unset Last-Modified
 Header set Expires “Fri, 08 Aug 2050 08:08:08 GMT”


# 禁止一个ip地址
 #deny from 118.195.*.*

RewriteCond %{REQUEST_FILENAME} -f
 RewriteCond %{REQUEST_FILENAME} ^.*\.(css|js|html|htm)$
 RewriteRule ^(.*)$ gzip.php?url=$1 [QSA,L]

#设置时间
 SetEnv TZ Asia/Chongqing

#阻止目录浏览
 Options All -Indexes



All times are GMT +8. The time now is 06:28 PM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.