【发布时间】:2011-11-19 08:27:00
【问题描述】:
在我的脚本中,这个函数部分构建链接:
if ($type == "mod_rewrite") {
$prepend = "";
$append = ".html";
} else if ($type == "query_string") {
$prepend = 'index.php?params=';
$append = "/";
}
//
//
//
$gamelink = 'game/id/gamename' (example)
/* 'game' is a fixed string.
'id' and 'gamename' are variables) */
我的 .htacess 如下:
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?params=$1 [NC,L]
问题:
我在游戏页面中有一个在查询字符串模式下完美运行的 ajax 评分栏:
(在此示例中:gamename = 'Arm Copter' 和 gameid = '3')
游戏链接:
http://localhost/gss/index.php?params=game/3/Arm-Copter/
评分链接(鼠标悬停的星星图片)
http://localhost/gss/plugins/ajax_star_rater/db.php?j=10&q=arm_copter&t=127.0.0.1&c=10
使用 ModRewrite: 游戏链接:
http://localhost/gss/game/3/Arm-Copter.html
评级链接(星号缺失,仅显示与星号对应的数字):
http://localhost/gss/game/3/plugins/ajax_star_rater/db.php?j=10&q=arm_copter&t=127.0.0.1&c=10
这里的问题,似乎是 url 部分 'game/id/' 插入,因为 db.php 的正确路径是:
http://localhost/gss/plugins/ajax_star_rater/db.php
而不是:
http://localhost/gss/**game/3/**plugins/ajax_star_rater/db.php
我花了 2 天时间搜索和测试各种方法,但我没有找到解决方案。我需要一个不重写 ajax 评级栏或重写为正确路径的规则。
问候,
大三 - 巴西。
【问题讨论】:
-
您使用哪些 URI 作为参考?您可能使用了“错误”的(可能是相对的)。
-
Hi Gumbo, // 我本地服务器上 Script 的本地路径:$cfg['instdir'] = 'D:/Program Files/wamp/www/gss/';我的脚本的 URL: $cfg['baseurl'] = 'localhost/gss'; ajax 星级评定者的路径:D:/Program Files/wamp/www/gss/plugins/ajax_star_rater/db.php 在我的 index.php 中,我有 ajax 星级评定者的链接:
标签: php javascript .htaccess mod-rewrite