将文本从url设置为网站
我正试图做到这一点: 例如,我有一个网站:将文本从url设置为网站,url,hyperlink,get,Url,Hyperlink,Get,我正试图做到这一点: 例如,我有一个网站: http://web.com 当我进去的时候 http://web.com/text 网站将是相同的,但将更改为文本 我进去的时候 http://web.com/title 网站将是相同的,但将更改为标题等。实现此目的的一种方法。 在您的.htaccess中 RewriteEngine on RewriteCond %{REQUEST_URI} !^/file.html$ RewriteRule .* /file.html [L,R=302] 在fi
http://web.com
当我进去的时候
http://web.com/text
网站将是相同的,但
将更改为文本
我进去的时候
http://web.com/title
网站将是相同的,但
将更改为标题
等。实现此目的的一种方法。
在您的.htaccess中
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/file.html$
RewriteRule .* /file.html [L,R=302]
在file.html中
<h1 id="header">text</h1>
<script type="text/javascript">
if (window.location.pathname != "/") {
document.getElementById("header").innerHTML = window.location.pathname;
}
</script>
文本
如果(window.location.pathname!=“/”){
document.getElementById(“header”).innerHTML=window.location.pathname;
}
它看不出你在尝试什么-到目前为止,你只想到了一个模糊的想法。你可以做一些类似于查询字符串的事情,或者从响应中获取url,然后从那里将其分解。你尝试过什么是一个更大的问题。试着使用Kelin,它是一个很棒的PHP路由器,可以让你做这样的事情,而且非常简单。显然,如果你不使用.htaccess或它被禁用,你必须以其他方式将所有请求指向file.html。