PHP URL重写和锚定Javascript

PHP URL重写和锚定Javascript,javascript,php,.htaccess,url-rewriting,anchor,Javascript,Php,.htaccess,Url Rewriting,Anchor,我正在尝试使用MVC进行开发,我访问的页面如下: http://localhost/app/dashboard/index <a href="#" data-toggle="myID">Item 1</a> <a href="dashboard/index/#" data-toggle="myID">Item 1</a> or <a href="http://localhost/app/dashboard/index/#" data-to

我正在尝试使用MVC进行开发,我访问的页面如下:

http://localhost/app/dashboard/index
<a href="#" data-toggle="myID">Item 1</a>
<a href="dashboard/index/#" data-toggle="myID">Item 1</a> or
<a href="http://localhost/app/dashboard/index/#" data-toggle="myID">Item 1</a>
dashboard是控制器et索引是类控制器dashboard中的函数

我有一个dispatcher页面(index.php),它重定向并调用正确的文件。 我有一个重写URL的.htaccess

RewriteEngine on
RewriteRule ^([a-zA-Z0-9\-\_\/]*)$ index.php?p=$1
所以当我访问
http://localhost/app/dashboard/index
$\u GET['p']=>仪表板/索引,因此我可以分解此数组并调用类

这很好,但我的问题是,当我创建一个链接时,假设要启动这样的jquery脚本:

http://localhost/app/dashboard/index
<a href="#" data-toggle="myID">Item 1</a>
<a href="dashboard/index/#" data-toggle="myID">Item 1</a> or
<a href="http://localhost/app/dashboard/index/#" data-toggle="myID">Item 1</a>
但它不起作用

请帮忙!
Alex

尝试将您的第一个链接更改为该链接。我只是在开头加了一个

<a href="/dashboard/index/#" data-toggle="myID">Item 1</a>

不,这让我想到:虽然一定是这样,但你只是试了一下吗?对不起,我猜是什么。实际上,我忘了为js文件编写正确的url。因此js文件未加载,并生成错误。