从 modifying/removing 特定指令 .htaccess 停止 wordpress
stop wordpress from modifying/removing a specific directive .htaccess
我在 .htaccess 文件中有这些行。
# BEGIN WordPress
# The directives (lines) between BEGIN WordPress and END WordPress are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^file-pdf.php$ wp-content/themes/astra-child/filepdf.php [QSA,L,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
第 4 行非常重要,因为这是一个别名,单击后它会转到另一个文件。我必须在她所在的地方保持这条线。
第 4 行
RewriteRule ^file-pdf.php$ wp-content/themes/astra-child/filepdf.php [QSA,L,NC]
我确实只使用了几个插件,但碰巧这一行已从 .htaccess 中删除,这破坏了应用程序的功能。
我已经阅读了这个在线教程中的一些要点,但我没有找到适合我的案例的解决方案。
我应该怎么做才能在这个代码块中维护这一行而不从任何插件更新甚至未来的 wordpress 版本更新中删除?
正如我所说。这一行实际上是一个指向另一个文件的别名,我还没有找到更好的方法来制作别名。所以我需要将这条线保持在那个块位置。或者使用另一种我不知道但可能有效的替代方法。
在此先感谢您。
这里是正在使用的 .htaccess 文件中的全部代码。
# 1° - Deny access to anyone surfing for it - 15:15 09.03.2021
<files wp-config.php>
order allow,deny
deny from all
</files>
# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.litespeed_conf\.dat - [F,L]
### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###
### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###
</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600
ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600
ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600
ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600
ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 A31557600
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/otf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 A31557600
</IfModule>
### marker BROWSER CACHE end ###
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
# BEGIN WordPress
# The directives (lines) between BEGIN WordPress and END WordPress are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^pdf-one.php$ wp-content/themes/astra-child/convertpdf.php [QSA,L,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# 3° - BEGIN BLOCK THE INCLUDE-ONLY FILES.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
# END BLOCK THE INCLUDE-ONLY FILES.
# 4° - BEGIN STOPS BOTS TRYING TO REGISTER IN WORDPRESS SITES THAT HAVE REGISTRATION DISABLED
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^action=register$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^.*registration=disabled$ [NC]
RewriteRule (.*) - [F]
</IfModule>
# 4° - END STOPS BOTS TRYING TO REGISTER IN WORDPRESS SITES THAT HAVE REGISTRATION DISABLED
# 5° - BEGIN BLOCK TRACE & TRACK REQUEST METHODS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)$
RewriteRule (.*) - [F]
</IfModule>
# 5° - END BLOCK TRACE & TRACK REQUEST METHODS
# 6° - BEGIN mod_deflate - website faster
<IfModule mod_deflate.c>
# Insert filters / compress text, html, javascript, css, xml:
# mod_deflate can be used for Apache v2 and later and is the recommended GZip mechanism to use
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/vtt
AddOutputFilterByType DEFLATE text/x-component
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/js
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/atom+xml
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/ld+json
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/font-sfnt
AddOutputFilterByType DEFLATE application/x-web-app-manifest+json
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/sfnt
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
# Exception: Images
SetEnvIfNoCase REQUEST_URI \.(?:gif|jpg|jpeg|png)$ no-gzip dont-vary
# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
# 6° - END mod_deflate - website faster
# 7° START - EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rdf+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/ld+json "access plus 0 seconds"
ExpiresByType application/schema+json "access plus 0 seconds"
ExpiresByType application/vnd.geo+json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 month"
ExpiresByType text/html "access plus 1 minute"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 months"
ExpiresByType application/x-javascript "access plus 1 months"
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"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/manifest+json "access plus 1 week"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"
</IfModule>
# 7° - END EXPIRES CACHING ##
# 8° - BEGIN Alternative caching using Apache's "mod_headers", if it's installed.
#Caching of common files - ENABLED
<IfModule mod_headers.c>
# 1 Month
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>
# 2 HOURS
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
</IfModule>
# 8° - END Alternative caching using Apache's "mod_headers", if it's installed.
# 9° BEGIN
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz|html|ttf)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
# 9° END
# 10° - BEGIN Set Keep Alive Header
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
# 10° - END Set Keep Alive Header
# 11° - BEGIN If your server don't support ETags deactivate with "None" (and remove header)
<IfModule mod_expires.c>
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
</IfModule>
# 11° - END If your server don't support ETags deactivate with "None" (and remove header)
# 14° - BEGIN adding font MIME types
<IfModule mod_mime.c>
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-opentype .otf
AddType image/svg+xml .svg
AddType application/x-font-ttf .ttf
AddType application/font-woff .woff
AddType application/font-woff2 .woff2
</IfModule>
# 14° - END
# 15° BEGIN DS-XML-RPC-API
# BEGIN WordPress
# The directives (lines) between "BEGIN DS-XML-RPC-API" and "END DS-XML-RPC-API" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<Files xmlrpc.php>
order deny,allow
deny from all
Allow from 122.248.245.244/32
Allow from 54.217.201.243/32
Allow from 54.232.116.4/32
Allow from 192.0.80.0/20
Allow from 192.0.96.0/20
Allow from 192.0.112.0/20
Allow from 195.234.108.0/22
Allow from 192.0.96.202/32
Allow from 192.0.98.138/32
Allow from 192.0.102.71/32
Allow from 192.0.102.95/32
</Files>
# 15° END DS-XML-RPC-API
# 16° BEGIN SECURITY POLICIES HEADER PROTOCOL
#
<IfModule mod_headers.c>
Header always set Content-Security-Policy "
default-src 'self' 5pila.com 'unsafe-inline';
script-src 'unsafe-eval';
# script-src 'self' https://m.addthis.com/live/red_lojson/300lo.json https://s7.addthis.com/js/300/addthis_widget.js https://z.moatads.com/addthismoatframe568911941483/moatframe.js;
# script-src-elem 'self' https://s7.addthis.com/js/300/addthis_widget.js?ver=80f4fcb896a389b28de3cdecff635a74;
script-src 'self' google-analytics.com ajax.googleapis.com;
script-src 'self' https://5pila.com/wp-content/themes/astra-child/assets/js/jquery-3.5.1.min.js?ver=1.0.0;
script-src 'self' https://5pila.com/wp-content/plugins/gdpr-cookie-compliance/dist/scripts/main.js?ver=4.4.6;
script-src 'unsafe-inline';
font-src 'self' https://fonts.gstatic.com;
font-src 'self' https://5pila.com/wp-content/themes/astra-child/assets/css/fonts/Roboto-Thin.woff?ver=2.4.5.1592433682;
font-src 'self' https://fonts.gstatic.com/s/roboto/v20/KFOkCnqEu92Fr1MmgVxFIzIFKw.woff2;
font-src 'self' https://fonts.googleapis.com/css?family=Raleway:400,300,200,500,600,700;
font-src 'self' https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,regular,italic,700,700italic&subset=latin-ext,greek-ext,cyrillic-ext,greek,vietnamese,latin,cyrillic;
base-uri 'self';
worker-src 'none';
img-src 'self' 5pila.com;
img-src https://5pila.com;
";
</IfModule>
# 16° END SECURITY POLICIES HEADER PROTOCOL
#
## 17° BEGIN
<IfModule mod_headers.c>
Header always set Permissions-Policy "geolocation=(),midi=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=(),sync-xhr=(),accelerometer=()"
##Header always set Permissions-Policy "geolocation=();midi=();notifications=();push=();sync-xhr=();accelerometer=();gyroscope=(); magnetometer=(); payment=(); camera=(); microphone=();usb=(); xr=();speaker=(self);vibrate=();fullscreen=(self);"
##Header always set Permissions-Policy "geolocation=(), midi=(),accelerometer=(), gyroscope=(), magnetometer=(), payment=(), camera=(), microphone=(), usb=()"
</IfModule>
## 17° END
## 18° BEGIN
<IfModule mod_headers.c>
Header always set Upgrade-Insecure-Requests: 1
</IfModule>
## 18° END
## 19° BEGIN
<IfModule mod_headers.c>
Header always set Cross-Origin-Embedder-Policy: "unsafe-none"
</IfModule>
## 19° END
## 20° BEGIN
<IfModule mod_headers.c>
Header always set Cross-Origin-Opener-Policy "same-origin"
</IfModule>
## 20° END
## 21° BEGIN
<IfModule mod_headers.c>
Header always set Cross-Origin-Resource-Policy "same-site"
</IfModule>
## 21° END
## 22° BEGIN
<IfModule mod_headers.c>
Header always set NEL "{}"
</IfModule>
## 22° END
## 23° BEGIN
<IfModule mod_headers.c>
Header always set Report_to "{}"
</IfModule>
## 23° END
## 24° BEGIN
<IfModule mod_headers.c>
Header always set Expect-CT "max-age=7776000, enforce, report-uri=https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
</IfModule>
## 24° END
## 25° BEGIN
<IfModule mod_headers.c>
Header always set Alt-Svc h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
</IfModule>
## 25° END
## 26° BEGIN
# off: Esta diretiva desativa a pré-busca de DNS.
# Isso é útil se você não monitora a referência das páginas
# ou se sabe que não deseja vazar informações para esses sites
<IfModule mod_headers.c>
Header always set X-DNS-Prefetch-Control "off"
</IfModule>
## 26° END
# END SECURITY POLICIES HEADER PROTOCOL
#
## 27° BEGIN
# BEGIN HARDEN YOUR .HTACCESS AND WP-CONFIG.PHP FILES
<files wp-config.php>
order allow,deny
deny from all
</files>
## 27° END
## 28° BEGIN
<Files .htaccess>
order allow,deny
deny from all
</Files>
# END HARDEN YOUR .HTACCESS AND WP-CONFIG.PHP FILES
## 28° BEGIN
# 29° BEGIN REDIRECTING HTTP TO HTTPS TRAFFIC ON APACHE
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[L,R=301]
</IfModule>
# 29° END REDIRECTING HTTP TO HTTPS TRAFFIC ON APACHE
## 30° BEGIN
# Wordfence WAF
<IfModule LiteSpeed>
php_value auto_prepend_file '/home/pilacom/public_html/wordfence-waf.php'
</IfModule>
<IfModule
lsapi_module>
php_value auto_prepend_file '/home/pilacom/public_html/wordfence-waf.php'
</IfModule>
<Files ".user.ini">
<IfModule
mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
# 30° END Wordfence WAF
## 31° BEGIN
# Disable Directory Indexing and Browsing
Options -Indexes
## 31° END
# 32° - BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
php_value upload_max_filesize 2M
php_flag zlib.output_compression On
</IfModule>
<IfModule lsapi_module>
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
php_value upload_max_filesize 2M
php_flag zlib.output_compression On
</IfModule>
# 32° - END cPanel-generated php ini directives, do not edit
## 33° BEGIN
## 33° END
# BEGIN DS-XML-RPC-API
# As diretrizes (linhas) entre "BEGIN DS-XML-RPC-API" e "END DS-XML-RPC-API" são
# geradas dinamicamente e só devem ser modificadas através de filtros do WordPress.
# Quaisquer alterações nas diretivas entre esses marcadores serão sobrescritas.
<Files xmlrpc.php>
order deny,allow
deny from all
Allow from 122.248.245.244/32
Allow from 54.217.201.243/32
Allow from 54.232.116.4/32
Allow from 192.0.80.0/20
Allow from 192.0.96.0/20
Allow from 192.0.112.0/20
Allow from 195.234.108.0/22
Allow from 192.0.96.202/32
Allow from 192.0.98.138/32
Allow from 192.0.102.71/32
Allow from 192.0.102.95/32
</Files>
# END DS-XML-RPC-API
# BEGIN PREVENT HOTLINKING
# RewriteEngine on
# RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?5pila.com [NC]
# RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
# END PREVENT HOTLINKING
# BEGIN DS-XML-RPC-FIX-HOTLINK
# As diretrizes (linhas) entre "BEGIN DS-XML-RPC-FIX-HOTLINK" e "END DS-XML-RPC-FIX-HOTLINK" são
# geradas dinamicamente e só devem ser modificadas através de filtros do WordPress.
# Quaisquer alterações nas diretivas entre esses marcadores serão sobrescritas.
# END DS-XML-RPC-FIX-HOTLINK
# sends all requests for “/” to “/Site/am/index.php”
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php72___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
I MUST maintain this line where she is.
该指令不需要进入 WordPress 代码块。您应该将该指令 放在 之前 # BEGIN WordPress
注释标记。这将防止它被 WordPress 覆盖。事实上,您可以将自定义规则放在文件的最顶部,以便于 find/maintain.
它的工作原理完全一样。
您不需要像其他指令那样将其封装在 <IfModule>
容器中。你不应该重复 RewriteEngine On
和 RewriteBase /
指令。 (这些特定指令的顺序无关紧要。事实上,last 实例“胜出”并控制整个文件。)
例如:
# Custom rules
RewriteRule ^file-pdf\.php$ wp-content/themes/astra-child/filepdf.php [L,NC]
# BEGIN WordPress
:
不要忘记在 RewriteRule
模式 中反斜杠转义文字点。这里不需要 QSA
标志。
旁白:
但是,您的其他一些规则顺序错误,因此无法正常工作。例如:
# 29° BEGIN REDIRECTING HTTP TO HTTPS
部分应该靠近文件顶部,在 WordPress 代码块/前端控制器之前。通过将它放在 WP 前端控制器之后,除了静态资源之外,它永远不会被处理。
部分 # 4°
和 # 5°
也应该 在 WordPress 代码块之前,否则它们不会阻止请求他们应该阻止。通常,阻塞指令应该在顶部。
您还有 3 个彼此 conflict/override 的缓存指令块。但是,似乎没有一个块是“主”块,您当前的缓存方案似乎是所有 3 个块的混合!
我在 .htaccess 文件中有这些行。
# BEGIN WordPress
# The directives (lines) between BEGIN WordPress and END WordPress are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^file-pdf.php$ wp-content/themes/astra-child/filepdf.php [QSA,L,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
第 4 行非常重要,因为这是一个别名,单击后它会转到另一个文件。我必须在她所在的地方保持这条线。
第 4 行
RewriteRule ^file-pdf.php$ wp-content/themes/astra-child/filepdf.php [QSA,L,NC]
我确实只使用了几个插件,但碰巧这一行已从 .htaccess 中删除,这破坏了应用程序的功能。
我已经阅读了这个在线教程中的一些要点,但我没有找到适合我的案例的解决方案。
我应该怎么做才能在这个代码块中维护这一行而不从任何插件更新甚至未来的 wordpress 版本更新中删除?
正如我所说。这一行实际上是一个指向另一个文件的别名,我还没有找到更好的方法来制作别名。所以我需要将这条线保持在那个块位置。或者使用另一种我不知道但可能有效的替代方法。
在此先感谢您。
这里是正在使用的 .htaccess 文件中的全部代码。
# 1° - Deny access to anyone surfing for it - 15:15 09.03.2021
<files wp-config.php>
order allow,deny
deny from all
</files>
# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.litespeed_conf\.dat - [F,L]
### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###
### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###
</IfModule>
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600
ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600
ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600
ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600
ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 A31557600
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/otf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 A31557600
</IfModule>
### marker BROWSER CACHE end ###
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
# BEGIN WordPress
# The directives (lines) between BEGIN WordPress and END WordPress are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^pdf-one.php$ wp-content/themes/astra-child/convertpdf.php [QSA,L,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# 3° - BEGIN BLOCK THE INCLUDE-ONLY FILES.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
# END BLOCK THE INCLUDE-ONLY FILES.
# 4° - BEGIN STOPS BOTS TRYING TO REGISTER IN WORDPRESS SITES THAT HAVE REGISTRATION DISABLED
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^action=register$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^.*registration=disabled$ [NC]
RewriteRule (.*) - [F]
</IfModule>
# 4° - END STOPS BOTS TRYING TO REGISTER IN WORDPRESS SITES THAT HAVE REGISTRATION DISABLED
# 5° - BEGIN BLOCK TRACE & TRACK REQUEST METHODS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)$
RewriteRule (.*) - [F]
</IfModule>
# 5° - END BLOCK TRACE & TRACK REQUEST METHODS
# 6° - BEGIN mod_deflate - website faster
<IfModule mod_deflate.c>
# Insert filters / compress text, html, javascript, css, xml:
# mod_deflate can be used for Apache v2 and later and is the recommended GZip mechanism to use
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/vtt
AddOutputFilterByType DEFLATE text/x-component
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/js
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/atom+xml
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/ld+json
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/font-sfnt
AddOutputFilterByType DEFLATE application/x-web-app-manifest+json
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/sfnt
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
# Exception: Images
SetEnvIfNoCase REQUEST_URI \.(?:gif|jpg|jpeg|png)$ no-gzip dont-vary
# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
# 6° - END mod_deflate - website faster
# 7° START - EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rdf+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/ld+json "access plus 0 seconds"
ExpiresByType application/schema+json "access plus 0 seconds"
ExpiresByType application/vnd.geo+json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 month"
ExpiresByType text/html "access plus 1 minute"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 months"
ExpiresByType application/x-javascript "access plus 1 months"
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"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/manifest+json "access plus 1 week"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"
</IfModule>
# 7° - END EXPIRES CACHING ##
# 8° - BEGIN Alternative caching using Apache's "mod_headers", if it's installed.
#Caching of common files - ENABLED
<IfModule mod_headers.c>
# 1 Month
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>
# 2 HOURS
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
</IfModule>
# 8° - END Alternative caching using Apache's "mod_headers", if it's installed.
# 9° BEGIN
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz|html|ttf)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
# 9° END
# 10° - BEGIN Set Keep Alive Header
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
# 10° - END Set Keep Alive Header
# 11° - BEGIN If your server don't support ETags deactivate with "None" (and remove header)
<IfModule mod_expires.c>
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
</IfModule>
# 11° - END If your server don't support ETags deactivate with "None" (and remove header)
# 14° - BEGIN adding font MIME types
<IfModule mod_mime.c>
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-opentype .otf
AddType image/svg+xml .svg
AddType application/x-font-ttf .ttf
AddType application/font-woff .woff
AddType application/font-woff2 .woff2
</IfModule>
# 14° - END
# 15° BEGIN DS-XML-RPC-API
# BEGIN WordPress
# The directives (lines) between "BEGIN DS-XML-RPC-API" and "END DS-XML-RPC-API" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<Files xmlrpc.php>
order deny,allow
deny from all
Allow from 122.248.245.244/32
Allow from 54.217.201.243/32
Allow from 54.232.116.4/32
Allow from 192.0.80.0/20
Allow from 192.0.96.0/20
Allow from 192.0.112.0/20
Allow from 195.234.108.0/22
Allow from 192.0.96.202/32
Allow from 192.0.98.138/32
Allow from 192.0.102.71/32
Allow from 192.0.102.95/32
</Files>
# 15° END DS-XML-RPC-API
# 16° BEGIN SECURITY POLICIES HEADER PROTOCOL
#
<IfModule mod_headers.c>
Header always set Content-Security-Policy "
default-src 'self' 5pila.com 'unsafe-inline';
script-src 'unsafe-eval';
# script-src 'self' https://m.addthis.com/live/red_lojson/300lo.json https://s7.addthis.com/js/300/addthis_widget.js https://z.moatads.com/addthismoatframe568911941483/moatframe.js;
# script-src-elem 'self' https://s7.addthis.com/js/300/addthis_widget.js?ver=80f4fcb896a389b28de3cdecff635a74;
script-src 'self' google-analytics.com ajax.googleapis.com;
script-src 'self' https://5pila.com/wp-content/themes/astra-child/assets/js/jquery-3.5.1.min.js?ver=1.0.0;
script-src 'self' https://5pila.com/wp-content/plugins/gdpr-cookie-compliance/dist/scripts/main.js?ver=4.4.6;
script-src 'unsafe-inline';
font-src 'self' https://fonts.gstatic.com;
font-src 'self' https://5pila.com/wp-content/themes/astra-child/assets/css/fonts/Roboto-Thin.woff?ver=2.4.5.1592433682;
font-src 'self' https://fonts.gstatic.com/s/roboto/v20/KFOkCnqEu92Fr1MmgVxFIzIFKw.woff2;
font-src 'self' https://fonts.googleapis.com/css?family=Raleway:400,300,200,500,600,700;
font-src 'self' https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,regular,italic,700,700italic&subset=latin-ext,greek-ext,cyrillic-ext,greek,vietnamese,latin,cyrillic;
base-uri 'self';
worker-src 'none';
img-src 'self' 5pila.com;
img-src https://5pila.com;
";
</IfModule>
# 16° END SECURITY POLICIES HEADER PROTOCOL
#
## 17° BEGIN
<IfModule mod_headers.c>
Header always set Permissions-Policy "geolocation=(),midi=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=(),sync-xhr=(),accelerometer=()"
##Header always set Permissions-Policy "geolocation=();midi=();notifications=();push=();sync-xhr=();accelerometer=();gyroscope=(); magnetometer=(); payment=(); camera=(); microphone=();usb=(); xr=();speaker=(self);vibrate=();fullscreen=(self);"
##Header always set Permissions-Policy "geolocation=(), midi=(),accelerometer=(), gyroscope=(), magnetometer=(), payment=(), camera=(), microphone=(), usb=()"
</IfModule>
## 17° END
## 18° BEGIN
<IfModule mod_headers.c>
Header always set Upgrade-Insecure-Requests: 1
</IfModule>
## 18° END
## 19° BEGIN
<IfModule mod_headers.c>
Header always set Cross-Origin-Embedder-Policy: "unsafe-none"
</IfModule>
## 19° END
## 20° BEGIN
<IfModule mod_headers.c>
Header always set Cross-Origin-Opener-Policy "same-origin"
</IfModule>
## 20° END
## 21° BEGIN
<IfModule mod_headers.c>
Header always set Cross-Origin-Resource-Policy "same-site"
</IfModule>
## 21° END
## 22° BEGIN
<IfModule mod_headers.c>
Header always set NEL "{}"
</IfModule>
## 22° END
## 23° BEGIN
<IfModule mod_headers.c>
Header always set Report_to "{}"
</IfModule>
## 23° END
## 24° BEGIN
<IfModule mod_headers.c>
Header always set Expect-CT "max-age=7776000, enforce, report-uri=https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
</IfModule>
## 24° END
## 25° BEGIN
<IfModule mod_headers.c>
Header always set Alt-Svc h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
</IfModule>
## 25° END
## 26° BEGIN
# off: Esta diretiva desativa a pré-busca de DNS.
# Isso é útil se você não monitora a referência das páginas
# ou se sabe que não deseja vazar informações para esses sites
<IfModule mod_headers.c>
Header always set X-DNS-Prefetch-Control "off"
</IfModule>
## 26° END
# END SECURITY POLICIES HEADER PROTOCOL
#
## 27° BEGIN
# BEGIN HARDEN YOUR .HTACCESS AND WP-CONFIG.PHP FILES
<files wp-config.php>
order allow,deny
deny from all
</files>
## 27° END
## 28° BEGIN
<Files .htaccess>
order allow,deny
deny from all
</Files>
# END HARDEN YOUR .HTACCESS AND WP-CONFIG.PHP FILES
## 28° BEGIN
# 29° BEGIN REDIRECTING HTTP TO HTTPS TRAFFIC ON APACHE
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[L,R=301]
</IfModule>
# 29° END REDIRECTING HTTP TO HTTPS TRAFFIC ON APACHE
## 30° BEGIN
# Wordfence WAF
<IfModule LiteSpeed>
php_value auto_prepend_file '/home/pilacom/public_html/wordfence-waf.php'
</IfModule>
<IfModule
lsapi_module>
php_value auto_prepend_file '/home/pilacom/public_html/wordfence-waf.php'
</IfModule>
<Files ".user.ini">
<IfModule
mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
# 30° END Wordfence WAF
## 31° BEGIN
# Disable Directory Indexing and Browsing
Options -Indexes
## 31° END
# 32° - BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
php_value upload_max_filesize 2M
php_flag zlib.output_compression On
</IfModule>
<IfModule lsapi_module>
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
php_value upload_max_filesize 2M
php_flag zlib.output_compression On
</IfModule>
# 32° - END cPanel-generated php ini directives, do not edit
## 33° BEGIN
## 33° END
# BEGIN DS-XML-RPC-API
# As diretrizes (linhas) entre "BEGIN DS-XML-RPC-API" e "END DS-XML-RPC-API" são
# geradas dinamicamente e só devem ser modificadas através de filtros do WordPress.
# Quaisquer alterações nas diretivas entre esses marcadores serão sobrescritas.
<Files xmlrpc.php>
order deny,allow
deny from all
Allow from 122.248.245.244/32
Allow from 54.217.201.243/32
Allow from 54.232.116.4/32
Allow from 192.0.80.0/20
Allow from 192.0.96.0/20
Allow from 192.0.112.0/20
Allow from 195.234.108.0/22
Allow from 192.0.96.202/32
Allow from 192.0.98.138/32
Allow from 192.0.102.71/32
Allow from 192.0.102.95/32
</Files>
# END DS-XML-RPC-API
# BEGIN PREVENT HOTLINKING
# RewriteEngine on
# RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?5pila.com [NC]
# RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
# END PREVENT HOTLINKING
# BEGIN DS-XML-RPC-FIX-HOTLINK
# As diretrizes (linhas) entre "BEGIN DS-XML-RPC-FIX-HOTLINK" e "END DS-XML-RPC-FIX-HOTLINK" são
# geradas dinamicamente e só devem ser modificadas através de filtros do WordPress.
# Quaisquer alterações nas diretivas entre esses marcadores serão sobrescritas.
# END DS-XML-RPC-FIX-HOTLINK
# sends all requests for “/” to “/Site/am/index.php”
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php72___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
I MUST maintain this line where she is.
该指令不需要进入 WordPress 代码块。您应该将该指令 放在 之前 # BEGIN WordPress
注释标记。这将防止它被 WordPress 覆盖。事实上,您可以将自定义规则放在文件的最顶部,以便于 find/maintain.
它的工作原理完全一样。
您不需要像其他指令那样将其封装在 <IfModule>
容器中。你不应该重复 RewriteEngine On
和 RewriteBase /
指令。 (这些特定指令的顺序无关紧要。事实上,last 实例“胜出”并控制整个文件。)
例如:
# Custom rules
RewriteRule ^file-pdf\.php$ wp-content/themes/astra-child/filepdf.php [L,NC]
# BEGIN WordPress
:
不要忘记在 RewriteRule
模式 中反斜杠转义文字点。这里不需要 QSA
标志。
旁白:
但是,您的其他一些规则顺序错误,因此无法正常工作。例如:
# 29° BEGIN REDIRECTING HTTP TO HTTPS
部分应该靠近文件顶部,在 WordPress 代码块/前端控制器之前。通过将它放在 WP 前端控制器之后,除了静态资源之外,它永远不会被处理。部分
# 4°
和# 5°
也应该 在 WordPress 代码块之前,否则它们不会阻止请求他们应该阻止。通常,阻塞指令应该在顶部。
您还有 3 个彼此 conflict/override 的缓存指令块。但是,似乎没有一个块是“主”块,您当前的缓存方案似乎是所有 3 个块的混合!