的.htaccess - 添加网址后,随机文字 [英] .htaccess - Add random text after url
问题描述
我做的.htaccess,可以在URL后加?比如 (site.com/page1?EXAMPLE)
i make a .htaccess that can add ?example after the url (site.com/page1?EXAMPLE)
但我想补充的随机数字或字母有 (site.com/page1?jsf6755saf)
but i like to add random numbers or letters there (site.com/page1?jsf6755saf)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !(^|&)EXAMPLE(&|$) [NC]
RewriteRule . %{REQUEST_URI}?EXAMPLE [L,QSA,R=302,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我怎么能做出这种
how i can make this
推荐答案
您将不得不使用类似RewriteMap指令中的Apache提供随机的文字。
You are going to have to use something like RewriteMap to provide random text in Apache.
那是他们唯一的方式,如果你想控制被放在那里的文本。
有一个的MapType RND ,可以拉随机文字到一个变量。
There is a MapType rnd that can pull random text into a variable.
http://httpd.apache.org/docs/2.0/ MOD / mod_rewrite.html#RewriteMap指令
下面是使用的一个例子。 创建具有这种结构的文本文件,并把管道连接到一起随机字符串。
Here is an example of usage. Create a text file with this structure and put random strings piped together.
map.txt的内容
Contents of map.txt
##
## map.txt -- rewriting map
##
random r3434fd|ssfsfs334|3542tgwet|w34rf235|32gvsr3|345343r|35fgew54e|bff534!q
注意:这不是一个完整的规则。只是一个例子,向您展示如何使用随机变量只是附加与%{服务器:随机}您的规则。
RewriteMap servers rnd:/path/to/file/map.txt
RewriteRule . %{REQUEST_URI}?%{servers:random} [L,QSA,R=302,NE]
Apache会再随机拉动从map.txt这些字符串中的一个,你要在你的查询字符串中使用。
Apache will then randomly pull one of those strings from map.txt to use in your query string that you want.
如果你只是想随机文本。
If you just want random text.
您还可以使用 UNIQUE_ID
You can also use the UNIQUE_ID
RewriteRule . %{REQUEST_URI}?%{UNIQUE_ID} [L,QSA,R=302,NE]
将推出类似 qOr5tEBvcm8AAE-VoiUAAAAQ
这篇关于的.htaccess - 添加网址后,随机文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!