【问题标题】:Trouble setting up nice urls with php / .htaccess [duplicate]无法使用 php / .htaccess 设置漂亮的 url [重复]
【发布时间】:2014-09-26 00:33:35
【问题描述】:

我在我的 php 网站上设置好网址时遇到问题,希望你们能在这里帮助我。

实际的网址现在看起来像这样: http://www.domain.com/product.php?op=showm&name=the-slug&id=id

我希望它看起来像这样: http://www.domain.com/products/the-slug/id 没有 id 甚至更好。

感谢任何帮助,非常感谢!

干杯

【问题讨论】:

  • 你试过解决这个重写问题吗?

标签: php .htaccess url-rewriting seo


【解决方案1】:

您想要的是来自mod rewrite 生成器的帮助。这是一个很好的。 http://www.generateit.net/mod-rewrite/index.php

您也可以尝试将以下内容添加到您的 .htaccess 文件中:

RewriteEngine On
RewriteRule ^products/([^/]*)/([^/]*)$ /product.php?op=showm&name=$1&id=$2 [L]

原网址:http://www.domain.com/product.php?op=showm&name=the-slug&id=id

改写后的网址:http://www.domain.com/products/the-slug/id

【讨论】:

    猜你喜欢
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    • 2016-01-25
    相关资源
    最近更新 更多