我有以下的ajax链接:
www.domain.com/profile#dashboard
是否可以通过htaccess将其更改为:
www.domain.com/profile/settings
如果是这样,怎么样? :d
修改
这是我的loadPages .js文件:
(document).ready(function() {
if (location.href.indexOf("#") > -1)
location.assign(location.href.replace('#', "/"));
//preload pages
if(window.location.hash) {
//Loading
var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
loadContent( hash+".php" ); }
});
function loadContent(pagina) {
jQuery("#page").load(pagina);
}
这是我的.htaccess文件
RewriteEngine On
RewriteBase /
#Hide de submap pages
RewriteRule ^$ pages/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ pages/$1
#Hide de logged-in file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ logged-in.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/logged-in\.php [NC]
RewriteRule ^ %1 [R=301,L]
以下是我在#pages div - dashboard页面中打开要打开的页面的示例
<a class="iconNav" href="#dashboard" id="loadDashboard" onclick="loadContent('dashboard.php');">
我更新了我的.htaccess文件。现在链接看起来像:
www.domain.com/#dashboard
我希望它是:
www.domain.com/dashboard
答案 0 :(得分:1)
您可以使用location.assign ( url )
方法更改浏览器中的网址:
if (location.href.indexOf("#") > -1)
location.assign(location.href.replace('#', "/"));