就差一点了,URL重写的问题,天杀呀!!!! 本帖最后由 daisy8675 于 2009-09-19 10:29:11 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 RewriteRule ^(.+)\.html$ /error404.php?url=$1 http://www.test.com/test/test.html这样的也被写了,只写根目录的*.html RewriteRule ^(.+)\.html$ /error404.php?url=$1无效,测试完毕!百度,Google都找半天都还只是那几个网页,换了一下顺序而已。有没有详细的重写规则的CHM格式的书呢? <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^?(.*)\.html$ /more.php?url=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^?(.*)$ /error404.php?url=$1 [L] </IfModule> 看看这个行不行,没时间帮你试. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^/?(.*)\.html$ /test.php?url=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /error404.php?url=$1 [L] </IfModule> 我实验了没有问题啊.都在第一条规则那边跳到test.php 谢谢,是真不行!这样http://test.com/test/test.html也被重写到test.php了。要求只写根目录下的*.html 原来是这个意思啊?晕死<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^([^/]+)\.html$ /test.php?url=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /test.php?url=error [L] </IfModule> 就是说不要让url有斜杠,而且是以.html 结尾的不就行了嘛..... 正解,但还有一个小问题存在,就是根目录也被重写了。比如:http://www.test.com输入后打开的肯定是http://www.test.com/这里就有一个/了,所以根目录也被重写了。还是一个问题! 同意11楼的 另外你说的http://www.test.com 打开后成为http://www.test.com/ 这个是正常的 不是被重写的,你随便输入一个网址http://www.163.com 都会变成http://www.163.com/。因为你已经RewriteBase /了 /下边没有匹配上的将不会被重写的 楼主试试这个<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^/?([^/]+)\.html$ /test.php?url=$1 [L]RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?(.*)$ /error404.php?url=$1 [L] </IfModule> Thinkphp和Codeigniter谁的思想好????? zend studio 不会用 怎么办 FTP上传出错 PHP查询结果无法正确显示的问题 使用ob_start生成静态页面在.net中有没有类似的方法 急招程序员!!!欢迎有实力的程序员加入 发布我的第1个PHP作品:E路文章系统PHP(Elook Article System.PHP) V1.0.0 whois 查询 请教:用php可以得到远程用户的ip,那如何用php得到远程用户的mac地址? 请问谁有用php编的mysql数据库在线管理工具 求一个正值表达式 比较怪的一个问题,如何让迅雷获得真实文件名和后缀
这样的也被写了,只写根目录的*.html
百度,Google都找半天都还只是那几个网页,换了一下顺序而已。
有没有详细的重写规则的CHM格式的书呢?
RewriteEngine On
RewriteBase /
RewriteRule ^?(.*)\.html$ /more.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^?(.*)$ /error404.php?url=$1 [L]
</IfModule> 看看这个行不行,没时间帮你试.
RewriteEngine On
RewriteBase /
RewriteRule ^/?(.*)\.html$ /test.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /error404.php?url=$1 [L]
</IfModule> 我实验了没有问题啊.都在第一条规则那边跳到test.php
这样http://test.com/test/test.html也被重写到test.php了。
要求只写根目录下的*.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)\.html$ /test.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test.php?url=error [L]
</IfModule>
就是说不要让url有斜杠,而且是以.html 结尾的不就行了嘛.....
比如:http://www.test.com输入后打开的肯定是http://www.test.com/
这里就有一个/了,所以根目录也被重写了。
还是一个问题!
因为你已经RewriteBase /了 /下边没有匹配上的将不会被重写的
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?([^/]+)\.html$ /test.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)$ /error404.php?url=$1 [L]
</IfModule>