【问题标题】:Results are not loaded after rewriting url with htaccess使用 htaccess 重写 url 后未​​加载结果
【发布时间】:2014-01-07 11:53:16
【问题描述】:

我已经使用htaccess 文件来重写 URL

之前我的网址是

http://example.com/New-York-Mills.php?ff_nm_from=new&search=hotel&location=north公园

htaccess改写后变成:

http://example.com/New-York-Mills/new/hotel/north+park

但现在没有显示结果。重写url后如何得到结果

Htaccess 代码:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+New-York-Mills\.php\?ff_nm_from=([^&]+)&search=([^&\ ]+)&location=([^&\ ]+)

RewriteRule ^ /New-York-Mills/%1/%2/%3? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^New-York-Mills/([^/]+)/([^/]+)/([^/]+)$ /New-York-Mills.php?
ff_nm_from=$1&search=$2&location=$3 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /style.css [NC]

【问题讨论】:

  • 提供您的 .htaccess 代码
  • 请使用 htaccess 代码编辑您的问题。它在评论中也不可读。
  • 看看这里:bit.ly/1cVDaAM 或者像 chanchal 说的,向我们展示你的 htaccess

标签: php .htaccess url rewrite


【解决方案1】:

怎么样?

RewriteRule http://example.com/(.+)/(.+)/(.+)/(.+)/? http://example.com/$1.php?ff_nm_from=$2&search=$3&location=$4

希望对您有所帮助,否则请向我们展示您的代码

【讨论】:

  • htaccess 规则在除 Firefox 之外的任何浏览器中都不起作用。请帮助我让他们在所有浏览器上工作。
  • 显示您的 htacces 代码。 htacces 是 apache 处理的,所以不是严格的浏览器问题,但可能你使用了一些奇怪的重写规则。
  • 我通过添加 /? 编辑了我的帖子在example.com/(.+)/(.+)/(.+)/(.+) 的末尾?试试它是否有效。还要检查是否没有其他重写可以捕获此操作。我会试着想想还有什么可以帮助的
【解决方案2】:

我试过这个重写规则:

重写规则http://example.com/(.+)/(.+)/(.+)/(.+)/? http://example.com/$1.php?ff_nm_from=$2&search=$3&location=$4

但没有显示结果,并且 htaccess 文件在除 Firefox 之外的任何浏览器中都不起作用。下面是我的 htaccess 代码。

RewriteCond %{THE_REQUEST} \ /+New-York-Mills.php\?ff_nm_from=([^&]+)&search=([^&\ ]+)&location=([^&\ ]+)

重写规则 ^ /New-York-Mills/%1/%2/%3? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

重写规则 ^New-York-Mills/([^/]+)/([^/]+)/([^/]+)$ /New-York-Mills.php?ff_nm_from=$1&search=$2 &location=$3 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /style.css [NC]

【讨论】:

    猜你喜欢
    • 2012-01-03
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 2011-04-03
    • 2014-12-23
    • 2015-01-25
    相关资源
    最近更新 更多