正如文件中所说:
“之间的指令(行)”;“开始WordPress”;和;结束WordPress“;是动态生成的,只能通过WordPress过滤器进行修改。这些标记之间对指令的任何更改都将被覆盖。
输入您的代码before #BEGIN WordPress
或after # END WordPress
.
然而,在[L]
标志表示LAST, 因此,如果该规则成功,将不会运行更多规则。
所以这个规则需要above 这个# BEGIN WordPress
试试这个.htaccess
:
# Just to be safe, wrap it in IfModule mod_rewrite.c, so that
# it does not kick in unless mod rewrite is enabled.
<IfModule mod_rewrite.c>
RewriteRule ^apply\\/? https://docs.google.com/forms/d/e/1FAIpQLSf5IrOhg0E_NAGZnOvMuaXhU80sio8bukaWVBkb87eEOa9kTw/viewform [L]
</IfModule>
# 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 ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
有一个很好的工具可以调试
.htaccess
文件名为
htaccess tester. 我准备了两个例子:
Why it won\'t work 当您的规则位于包含RewriteRule . /index.php
.✅ The fully working example 我在上面发帖。