在Windows 10上使用自定义php(xampp)中的.htaccess重写URL

时间:2017-04-29 13:47:45

标签: php .htaccess url-rewriting

我想重写以下网址:

public static String getAddress(List<Hus> list){
    if(list.isEmpty()){
        return "no address";
    } else {
        return list.get(0).getAddress();
    }
}

为此,我在report目录中写了以下.htaccess文件,该目录是网站root的子目录:

www.phcc.com/reports/caseFullDtlByCaseSno.php?case_sno=1

  To

http://www.phcc.com/reports/1/caseFullDtlByCaseSno.html

但它没有完成请求,因为我需要它。 我该怎么办?

1 个答案:

答案 0 :(得分:1)

尝试下面,我假设html文件不存在。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\d]+)/([\w-]+)\.html$ $2.php?case_sno=$1 [L]