Rewrite规则应该怎么写
Rewrite规则应该怎么写:我写了个小偷站,URL格式是:http://www.xxx.net/article?id=23766现在我想通过Rewrite伪静态,/ar...
Rewrite规则应该怎么写:
我写了个小偷站,URL格式是:http://www.xxx.net/article?id=23766
现在我想通过Rewrite伪静态,/article/bcgff.html来访问,就是将URL中的数字替换成相应的字母,如:1替换成a,2替换成b,3替换成c...以此类推。Rewrite规则怎样写?
请问flowithwind,改脚本的方法是什么,请指教。。谢谢! 展开
我写了个小偷站,URL格式是:http://www.xxx.net/article?id=23766
现在我想通过Rewrite伪静态,/article/bcgff.html来访问,就是将URL中的数字替换成相应的字母,如:1替换成a,2替换成b,3替换成c...以此类推。Rewrite规则怎样写?
请问flowithwind,改脚本的方法是什么,请指教。。谢谢! 展开
展开全部
apache的话这么写
RewriteMap flowithwind txt:path/to/a/mapfile.txt
RewriteRule ^/article/(.*)a(.*) /article/$1${flowithwind:a}$2 [N]
RewriteRule ^/article/(.*)b(.*) /article/$1${flowithwind:b}$2 [N]
RewriteRule ^/article/(.*)c(.*) /article/$1${flowithwind:c}$2 [N]
RewriteRule ^/article/(.*)d(.*) /article/$1${flowithwind:d}$2 [N]
RewriteRule ^/article/(.*)e(.*) /article/$1${flowithwind:e}$2 [N]
RewriteRule ^/article/(.*)f(.*) /article/$1${flowithwind:f}$2 [N]
RewriteRule ^/article/(.*)g(.*) /article/$1${flowithwind:g}$2 [N]
RewriteRule ^/article/(.*)h(.*) /article/$1${flowithwind:h}$2 [N]
RewriteRule ^/article/(.*)i(.*) /article/$1${flowithwind:h}$2 [N]
RewriteRule ^/article/(.*)j(.*) /article/$1${flowithwind:h}$2 [N]
RewriteRule ^/article/(\d+).html /article?id=$1&{%QUERY_STRING} [L,NC]
然后path/to/a/mapfile.txt文件这么写
a 1
b 2
c 3
d 4
e 5
f 6
g 7
h 8
i 9
j 0
都搞定之后重启apache就可以了。
不过这样做,apache需要进行N多次的rewrite,对性能会有一定影响,不过就不用改脚本了。
补充:
如果你的/article最终会提交给一个脚本执行(比如php),那你只需要保留
RewriteRule ^/article/(\w+).html /article?id=$1&{%QUERY_STRING} [L,NC]
在httpd.conf中就行了。
然后在脚本中从request_uri中提取出(\w+)部分,自己做一个替换就行了,可以用spreg_replace(array('/a/',/b/',..),array('1','2',...), $srcstr);
RewriteMap flowithwind txt:path/to/a/mapfile.txt
RewriteRule ^/article/(.*)a(.*) /article/$1${flowithwind:a}$2 [N]
RewriteRule ^/article/(.*)b(.*) /article/$1${flowithwind:b}$2 [N]
RewriteRule ^/article/(.*)c(.*) /article/$1${flowithwind:c}$2 [N]
RewriteRule ^/article/(.*)d(.*) /article/$1${flowithwind:d}$2 [N]
RewriteRule ^/article/(.*)e(.*) /article/$1${flowithwind:e}$2 [N]
RewriteRule ^/article/(.*)f(.*) /article/$1${flowithwind:f}$2 [N]
RewriteRule ^/article/(.*)g(.*) /article/$1${flowithwind:g}$2 [N]
RewriteRule ^/article/(.*)h(.*) /article/$1${flowithwind:h}$2 [N]
RewriteRule ^/article/(.*)i(.*) /article/$1${flowithwind:h}$2 [N]
RewriteRule ^/article/(.*)j(.*) /article/$1${flowithwind:h}$2 [N]
RewriteRule ^/article/(\d+).html /article?id=$1&{%QUERY_STRING} [L,NC]
然后path/to/a/mapfile.txt文件这么写
a 1
b 2
c 3
d 4
e 5
f 6
g 7
h 8
i 9
j 0
都搞定之后重启apache就可以了。
不过这样做,apache需要进行N多次的rewrite,对性能会有一定影响,不过就不用改脚本了。
补充:
如果你的/article最终会提交给一个脚本执行(比如php),那你只需要保留
RewriteRule ^/article/(\w+).html /article?id=$1&{%QUERY_STRING} [L,NC]
在httpd.conf中就行了。
然后在脚本中从request_uri中提取出(\w+)部分,自己做一个替换就行了,可以用spreg_replace(array('/a/',/b/',..),array('1','2',...), $srcstr);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询