【问题标题】:How to Write a rewrite rule in my sub directory htaccess file to achieve this如何在我的子目录 htaccess 文件中编写重写规则来实现这一点
【发布时间】:2020-10-13 13:01:03
【问题描述】:

我的公共 html 文件夹下有一个名为“apps”的子目录。我获取“apps”数据库表记录并显示 index.php 文件中的一些记录,并提供指向另一个文件的链接以显示更多记录特定的行。 我在显示所选行的完整记录的同一目录中有另一个名为“details.php”的文件。

我的链接是这样的

<a href="details.php?
name=APP_NAME">APP NAME 
</a>

其中 APP_NAME 在数据库表中是唯一的。

假设我的数据库中有一个名为“oreo”的应用程序 然后链接看起来像

<a href="details.php?
name=oreo">oreo 
</a>

我想重写这个 url 让它像这样对 seo 友好

<a href="oreo">oreo 
</a>

完整的网址将如下所示

https://example.com/apps/oreo

我试过这段代码,但它不起作用

RewriteRule ^/apps/(.*)$ 
/details.php?name=$1  

我对重写规则不太清楚..所以我需要帮助..

【问题讨论】:

    标签: php .htaccess url-rewriting


    【解决方案1】:

    知道了,可以了

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /apps/details.php?name=$1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      • 2018-03-14
      • 2021-04-10
      • 1970-01-01
      • 2012-11-22
      相关资源
      最近更新 更多