【问题标题】:Use full names in url, instead of something like "index.php?id=0"在 url 中使用全名,而不是像“index.php?id=0”这样的东西
【发布时间】:2013-06-06 07:30:42
【问题描述】:

去年我从零开始创建了自己的网站。虽然没什么大不了,但我想通过替换笨拙、难记的 URL 来改进它。

所以,我非常想从“http://www.iubuntu.cz/index.php?id=0”转到“http://www.iubuntu.cz/”,从“http://www.iubuntu.cz/index.php?id=1”转到“http://www.iubuntu.cz/desktop”。

有人可以将我重定向到有关此的一些信息吗?我试图通过 Google 找到一些东西,但似乎我无法提出正确的问题。

非常感谢。

【问题讨论】:

  • 在.htaccess文件中使用url重写。
  • 使用可以使用htacesss和url-rewrite ...

标签: php web


【解决方案1】:

您需要考虑使用 .htaccess 重写 URL。

Here's Smashing Magazine 的介绍文章。

【讨论】:

    【解决方案2】:

    为了使您的网站 url 用户友好和 SEO 友好,您可以通过 URL 重写来实现。这意味着您的原始 URL 将映射到对 SEO 友好的自定义 URL。 例如“http://www.iubuntu.cz/index.php?id=0”到“http://www.iubuntu.cz/desktop”。

    为此,您需要知道 .htaccess。这是使用 htaccess 重写 url 的示例。

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    RewriteRule ^Users/home$ http://www.example.com/ [L,R=301]
    RewriteRule ^index.php$ http://www.example.com/ [L,R=301] 
    </IfModule>
    

    要了解更多信息,请查看此链接,它非常有用。 http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-19
      • 1970-01-01
      • 2020-03-24
      • 2013-05-02
      • 1970-01-01
      • 2011-01-24
      • 1970-01-01
      • 2023-03-06
      相关资源
      最近更新 更多