htaccess:向 URL 添加随机字符串 [英] htaccess: Add random string to URL

查看:54
本文介绍了htaccess:向 URL 添加随机字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的网址:
http://www.foobar.com/

I'm having a URL like this:
http://www.foobar.com/

如果用户输入它,我希望 URL 被一个随机字符串扩展,如

If a user enters it, I want the URL to be expanded by a random string like

http://www.foobar.com/f896c0fb0924db5dfeae58d430c2d6ca
(在示例中添加了 MD5,但其他任何内容也都可以.)

是否可以通过 .htaccess 和一些聪明的重写规则来做到这一点?

Is it possible to do this via .htaccess and some clever Rewrite-rules?

推荐答案

使用 mod_rewrite 可以做到,但是 编程模式 (prg) 需要在服务器配置中定义(你只能从 .htaccess).您可以使用一长串预定义字符串 (meh) 或使用其他伪随机源.一种选择是结合各种TIME 服务器变量,如TIME_SEC.有重复和没有分隔符,不容易注意到模式.

It is possible to do it with mod_rewrite, but the programmatic mode (prg) needs to be defined in the server config (you can only use them then from .htaccess). You could come close with a long chain of predefined strings (meh) or use other pseudo-random sources. One option is to combine various TIME server variables like TIME_SEC. With repeats and without separators, it would not be easy to notice the pattern.

这篇关于htaccess:向 URL 添加随机字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆