htaccess: Add random string to URL

主宰稳场 提交于 2020-01-26 04:14:21

问题


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

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

http://www.foobar.com/f896c0fb0924db5dfeae58d430c2d6ca
(In the example a MD5 is added, but it anything else would be fine too.)

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


回答1:


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.



来源:https://stackoverflow.com/questions/14778226/htaccess-add-random-string-to-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!