问题
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