[英]Pass parameter to WordPress plugin with pretty url, mod_rewrite, .htaccess
I told WordPress that I wanted urls to look like: domain.com/postname.html
我告诉WordPress,我希望网址看起来像:
domain.com/postname.html
I want to pass a parameter to a WordPress plugin. 我想将参数传递给WordPress插件。 So when I get domain.com/postname.html.2 it is supposed to be domain.com/postname.html?tubepress_page=2
所以当我得到domain.com/postname.html.2时,应该是domain.com/postname.html?tubepress_page=2
With the following the parameter is passed correctly, but not the name. 使用以下参数可以正确传递参数,但不能正确传递名称。
This is the .htaccess
file: 这是
.htaccess
文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^.*([0-9]+)$ /?tubepress_page=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
So for URL domain.com/postname.html.2
The above .htaccess
basically works, it gives me the correct parameter to the script, but not the correct page, it gives me the latest WordPress post. 因此,对于URL
domain.com/postname.html.2
,上述.htaccess
基本上可以正常运行,它为脚本提供了正确的参数,但没有正确的页面,因此为我提供了最新的WordPress帖子。
I think it somehow is missing the post name, but I don't know how to specify that in the RewriteRule. 我认为它以某种方式缺少职位名称,但是我不知道如何在RewriteRule中指定该名称。
I get the same if I type: domain.com/.2 which gives me the latest post. 如果键入:domain.com/.2,则得到的信息相同。
So what would be good domain.com/xyz.html.2 to be tubepress_page=2 for the page xyz and I don't want to specify xyz.html anywhere in the htaccess file, since I want to try to avoid typing in things for each new post I make. 因此,对于页面xyz来说,domain.com/xyz.html.2最好是tubepress_page = 2,我不想在htaccess文件中的任何地方指定xyz.html,因为我想避免输入任何东西对于我发布的每个新帖子。
How do I specify it so that the post name variable is taken into consideration in the RewriteRule? 如何指定它,以便在RewriteRule中考虑帖子名称变量?
Any help on this would be very much appreciated. 任何帮助,将不胜感激。
尝试以下规则:
RewriteRule ^(.*\.html)\.([0-9]+)$ $1?tubepress_page=$2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.