【问题标题】:Wordpress Htaccess URL Rewriting with GET parameter使用 GET 参数重写 Wordpress Htaccess URL
【发布时间】:2019-04-01 15:09:28
【问题描述】:

我的网站在 wordpress 上。我想重写网址。 就像这是我的主题索引页面的网址

http://localhost/wp/?id=test

我想要这样 http://localhost/wp/test

我可以在哪里将此“测试”作为 GET 参数。

【问题讨论】:

  • 清理您的 .htaccess 文件并将永久链接设置为帖子类型

标签: php wordpress .htaccess


【解决方案1】:

请前往:

Wordpress 管理 -> 设置 -> 固定链接

并将“/%category%/%postname%/”设置为自定义结构。

【讨论】:

  • 这样做后我将如何在我的页面中获取获取参数值?因为现在写它正在将我重定向到未找到的页面
  • 您需要在主题文件夹中有此帖子类型的模板文件。在这个文件中,您可以使用 $post 对象 (codex.wordpress.org/Function_Reference/$post) 从这个参数中获取任何数据。
【解决方案2】:

如果您使用的是 linux 虚拟主机,请转到 /wp-admin/options-permalink.php 并选择“帖子名称”。

如果您使用的是 Windows 虚拟主机,

If you are using linux web hosting, go here /wp-admin/options-permalink.php and select 'post name'.

If you are using windows web hosting, create a web.config file and paste below codes.

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”wordpress” patternSyntax=”Wildcard”>
<match url=”*” />
<conditions>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
</conditions>
<action type=”Rewrite” url=”index.php” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

【讨论】:

    猜你喜欢
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多