Php js从样式化url获取查询字符串

Php js从样式化url获取查询字符串,php,javascript,.htaccess,Php,Javascript,.htaccess,是否有方法从使用.htaccess更改的URL获取查询字符串。例如,如果我的url是这样的 http://mysite.com/blog.php?id=7 RewriteRule ^blog/([0-9]+)$ blog.php?id=$1 [NC,L] 在本例中,location.search可以工作,php&_GET['id']也可以工作,但是如果我像这样更改htaccess http://mysite.com/blog.php?id=7 RewriteRule ^blog/([0-9

是否有方法从使用.htaccess更改的URL获取查询字符串。例如,如果我的url是这样的

http://mysite.com/blog.php?id=7
RewriteRule ^blog/([0-9]+)$ blog.php?id=$1 [NC,L]
在本例中,location.search可以工作,php&_GET['id']也可以工作,但是如果我像这样更改htaccess

http://mysite.com/blog.php?id=7
RewriteRule ^blog/([0-9]+)$ blog.php?id=$1 [NC,L]
url将更改为

http://mysite.com/blog/7
现在只有$_GET['id']可以工作,但javascript版本不能工作


谢谢您,Daniel。

您需要使用
location.pathname.substr(1.split(“/”)
手动拆分URL


这将为您提供一个包含各种路径段的数组。在您的例子中,它将包含
['blog','7']

谢谢,我99%确定您无法获得php提供的字符串。