【发布时间】:2017-03-22 02:29:05
【问题描述】:
我知道有一千个重复的帖子,但到目前为止对我没有任何帮助。
我正在尝试使用重写规则将/articulo.html?id=friendly-url 转换为/articulo/friendly-url
这是我在 .htaccess 中使用但没有成功:
RewriteEngine On
RewriteRule ^articulo/(.*)$ /articulo.html?id=$1 [L]
编辑:
这是寻找id参数的js:
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
console.warn(sPageURL);
console.warn(sURLVariables);
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
【问题讨论】:
标签: javascript .htaccess url-rewriting