1
我知道有一千关于这个重复的帖子,但迄今没有任何工作。重写规则与网址参数
我试图用一个重写规则变换/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];
}
}
};
不,结果是一样的。它加载了articulo.html,因为路由改变而没有css和js。寻找id参数的js也不起作用。 – cerealex
要正确加载css和js,请在头部使用' ''。 –
虽然有效,但它不能解决脚本无法通过URL更改检查ID的问题。我想这是预期的方式,我需要重构代码以查找ID后面的/? – cerealex