Wordpress 如何删除?从使用htaccess的url

Wordpress 如何删除?从使用htaccess的url,wordpress,apache,.htaccess,url,seo,Wordpress,Apache,.htaccess,Url,Seo,我有一个网址 我需要把它改成 如何删除?使用Htaccess(Wordpress)从URL 我使用下面的htaccess代码。但它不起作用 RewriteEngine On RewriteBase / RewriteRule ^index\.php-$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /domain.com/index.php [L] RewriteRule ^/postname/([0-9]+)$ /? $1 [L

我有一个网址

我需要把它改成

如何删除?使用Htaccess(Wordpress)从URL

我使用下面的htaccess代码。但它不起作用

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php-$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /domain.com/index.php [L]
RewriteRule ^/postname/([0-9]+)$ /? $1 [L,QSA] 

规则匹配字符串去掉查询字符串(后面的所有内容?)。所以你想放弃这个计划?并像这样显式使用查询字符串(而不是上一条规则)

请注意,您应该删除前导/,因为这与.htaccess规则匹配字符串删除前导/;还注意到了吗?在替换模式中,省略QSA标志,因为您不想附加查询字符串


同时将此规则移动到前一个cond/规则之上,因为第二个规则将在您的postname模式上触发,因此除非将其向上移动一个,否则您将永远无法使用此规则

请对您的示例域使用
example.com
,而不是
domain.com
(该域可能不是您自己所有)。
RewriteCond %{QUERY_STRING} ^([\w\-]+)$
RewriteRule ^postname/$ postname/%1?   [L]