所以我需要将site.com/plugin-page/1234的URL重写为site.com/wp-content/plugins/the-plugin/packages/1234
但由于某种原因,URL会重定向,而不仅仅是重写。我需要它只是重写,而不是重定向。
这是我的.htaccess代码。
# 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]
RewriteRule ^plugin-page/?(.*)$ /wp-content/plugins/the-plugin/packages/$1/index.html [L]
</IfModule>
# END WordPress
规则的顺序非常重要,请按以下方式尝试:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^plugin-page/([0-9]+)/?$ /wp-content/plugins/the-plugin/packages/$1/index.html [NC,L]
RewriteRule ^index/.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
最有可能发生的情况是,由于您的规则是上一个WP试图在其代码中自行查找它,从而导致了重定向而不是内部重定向。
另外,请确保index.html
存在您内部重定向到的路径。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句