0
我需要添加一些代碼到我的.htaccess文件。但我不清楚在哪裏粘貼它,因爲我的.htaccess文件中有WordPress代碼。將.htaccess代碼粘貼到WordPress htaccess代碼的上方或下方?
代碼:WordPress的代碼
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
有人能告訴我在哪裏插入 「代碼B」(見下文)?這應該超出或低於WordPress的.htaccess代碼?如果它應該超出,我是否需要從Wordpress代碼中刪除RewriteEngine On
並將其放在最頂端?請回復代碼,以便我可以直觀地看到正確的方式來執行此操作。
代碼B:我的代碼
#Specify IP Allowed to Login
<Files wp-login.php>
order deny,allow
deny from all
allow from 12.345.67.890
</Files>
代碼C:是下面的.htaccess順序是否正確?如果不是,你能告訴我正確的順序嗎?應該RewriteEngine On
接近頂部?
Options +FollowSymLinks
#Specify IP Allowed to Login
<Files wp-login.php>
order deny,allow
deny from all
allow from 12.345.67.891
</Files>
#STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
<files wp-config.php>
Order allow,deny
Deny from all
</files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#Prevent directory browsing
Options All -Indexes
#Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#Redirect index.html
RewriteCond %{THE_REQUEST} ^.*/index.html [NC]
RewriteRule ^(.*)index.html$ http://www.domain.com/$1 [R=301,L]
#Redirect IP Address
RewriteCond %{HTTP_HOST} ^123\.456\.789\.999$
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
#Force Trailing Slash
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.domain.com/$1/ [L,R=301]
#Stop Hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)domain.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|bmp|zip|rar|mp3|flv|swf|xml|php|png|css|pdf)$ - [F]
感謝anubhava。我有更多的指令的東西插入和想要了解在哪裏插入這些沒有結合現有的WP .htaccess - 你能證明在哪裏插入指令?你也可以在哪裏插入'Options + FollowSymLinks'? –
leko
2014-11-01 07:12:28
anubhava,我仍然不確定.htaccess的正確順序 - 你可以在我的帖子中查看「CODE C」嗎?我剛剛看了一些.htaccess教程,我仍然感到困惑。我被告知重定向規則應該靠近頂部,所以我會將所有重定向規則放在''之上,因此WordPress .htaccess代碼將處於最底層? –
leko
2014-11-01 09:09:33
非常感謝anubhava !!!真的很感謝你的幫助! – leko 2014-11-01 10:14:19