【问题标题】:How can I create a .htaccess on localhost (Appserv)如何在 localhost (Appserv) 上创建 .htaccess
【发布时间】:2018-11-20 19:01:11
【问题描述】:

我尝试了太多示例,但我没有成功重写规则。

这就是想要的:

这个地址:localhost/admin/page.php?id=25 变成:localhost/admin/settings

“settings”是page.php中的一个变量

你能帮帮我吗?

【问题讨论】:

标签: php .htaccess localhost


【解决方案1】:

您是否尝试过以下方法?

RewriteEngine On 
RewriteRule    ^admin/settings/?$  admin/page.php?id=25 [NC,L] 

【讨论】:

  • 我将在哪里使用包含“设置”值的变量?
  • 您希望它如何工作?根据我从问题中收集到的信息,您希望 localhost/admin/settings 将您带到 localhost/admin/page.php?id=25 在您的示例中,除了 ?id=25 之外没有变量值
  • 我想要完全相反的你写的。 localhost/admin/page.php?id=25 to => localhost/admin/settings
  • 但这有什么意义呢?每当您创建一个链接说localhost/admin/page.php?id=25 时,您将改为创建链接localhost/admin/settings。重写的目的是使 URL 更易于阅读和记忆。也许我不了解大局
  • 我的数据库中有数千个条目,我在 page.php 中选择并打印这些条目。而不是 page.php?id=xx ,我想使用我写的链接格式。用户将更容易使用该网站。
猜你喜欢
  • 1970-01-01
  • 2013-02-20
  • 2012-04-17
  • 2017-09-26
  • 1970-01-01
  • 2014-04-29
  • 2016-04-14
  • 2021-06-02
  • 2017-06-09
相关资源
最近更新 更多