关于Url_ReWrite功能

#1 cody

我tpl中用<{spUrl c=forAjax a=detail D_id=$one.D_id}>生成了http://localhost/forAjax-detail-D_id-116.html这个网址不能用,
自己打http://localhost/index.php?c=forAjax&a=detail&D_id=116就可以,为什么呢?是不是要改什么?

2010-11-16 18:07:28

#2 jake

“不能用”的意思是不是404错误呢?

请先确定你的服务器是否支持URLREWRITE和htaccess文件是否已经正确设置,

访问http://localhost/xxx.html都会直接转到http://localhost/index.php就是正确设置了。

2010-11-16 20:06:22

#3 cody

没有提示,一片空白!服务器支持URLREWRITE!
URLREWRITE设置和htaccess,都是用你写的文件!
 BEGIN WinBlog

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

END WinBlog


这个RewriteRule,后面是不是要加点东西才可以带get的参数?

2010-11-16 20:18:38

#4 jake

访问
http://localhost/任何页面.html
都会显示
http://localhost/
的内容,才是正确配置。

另外,可以在本论坛找之前的一些URLREWRITE的例子下来试试:
http://speedphp.com/bbs/thread-1040-1-2.html
还有,本站的SPeedAMP服务器套装是默认支持URLREWRITE的,楼主可以试试。

2010-11-16 20:58:02

#5 cody

我用PHPnow,默认也是开启URLREWRITE,我的设置和你给的例子一样,但就是不行:(
 
function detail(){
  dump($this->spArgs());
  echo "haha";
  $D_id = $this->spArgs("Did");
  dump($D_id);  
  $detail = spClass("dslam")->findBy("D_id",$D_id);
  dump($detail);
}

我访问http://localhost/forAjax-detail-Did-12.html,页面显示
 
Array
(
    [forAjax-detail-Did-12_html] =>
    [user] => Arrayuname
    [PHPSESSID] => ps8sbqbpm4kgv3p6o478k8la83
    [did] => 12
)
haha

我知道原因了,我将  $D_id = $this->spArgs("Did");
中的("Did")改为("did")就成功了,为什么会自动变为小写呢?

2010-11-16 21:23:31

#6 cody

我想就是这个原因了,可不可以设置区分大小写呢?

2010-11-16 22:26:55

#7 jake

我想就是这个原因了,可不可以设置区分大小写呢?
cody 发表于 2010-11-16 22:26
URL地址本身就是不区分大小写的。这是浏览器的特性。

2010-11-17 08:25:23