用htaccess重写url后没有加载结果

时间:2014-01-07 11:53:17

标签: php .htaccess url rewrite

我使用htaccess文件重写网址

之前我的网址是

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

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]

2 个答案:

答案 0 :(得分:0)

怎么样?

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

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

答案 1 :(得分:0)

我尝试过这个重写规则:

RewriteRule http://example.com/(.+)/(.+)/(.+)/(.+)/http://example.com/ $ 1.PHP ff_nm_from = $ 2及?查询= $ 3及位置= $ 4

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

RewriteCond%{THE_REQUEST} \ /+New-York-Mills.php \?ft_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]