【问题标题】:How to mod-rewrite the url with custom extension如何使用自定义扩展名重写 url
【发布时间】:2015-08-10 20:41:41
【问题描述】:

我需要将我的 url 模式从正常路径更改为子域。我尝试编写 .htaccess 但它不起作用。

http://hello.com/sos/article.php?id=1&title=this-is-a-title.php

从上面的网址我想:

  1. 更改调用页面的模式,因此我将域之前的sos 删除为子域。所以我得到了http://sos.hello.com/
  2. 我需要将变量替换为正斜杠并以.sos 为后缀。因为故事是关于警告的:article/1/this-is-a-title.sos

我希望我能有这样的东西: http://sos.hello.com/article/1/this-is-a-title.sos

所以我写了:

RewriteEngine On
RewriteRule ^article/([^/]*)/([^/]*)\.sos$ /article.php?id=$1&title=$2 [L]

你猜怎么着!这行不通。请指出我。我做错了什么???

【问题讨论】:

    标签: mod-rewrite seo subdomain file-extension


    【解决方案1】:

    经过多次尝试,我得到了答案:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.hello.com
    RedirectMatch 301 ^/sos/$ http://sos.hello.com/mypage.php
    RewriteRule ^article/([^/]*)/([^/]*)\.sos$ /article.php?id=$1&title=$2 [L]
    

    另存为.htaccess到子域目录

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-06
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 2013-09-15
      • 1970-01-01
      • 2013-11-17
      相关资源
      最近更新 更多