问题是我基于GET方法捕获我的网址...所以我的网址看起来像
localhost/test/index.php?vic=24
其中vic是可变的......
我的网站上还有一个按钮,每次随机化我的vic。
<a href="'.htmlentities($_SERVER['PHP_SELF']).'?vic='.randomVic($link).'">
请注意,randomVic($ link)是一个每次都返回随机数的函数。
我想要实现的是我的网址看起来像
localhost/test/index.php?vic=24 -> localhost/test/24
每个随机数等等。 我真的需要帮助,我尝试了很多.htacces mods进行重写(条带化.php,删除索引,......)但是没有一个能够工作,因为我需要它们。
谢谢!
答案 0 :(得分:0)
RewriteRule ^test/([0-9]+)$ index.php?vic=$1
根据以下评论进行编辑
答案 1 :(得分:0)
启用mod_rewrite
和.htaccess
至httpd.conf
(如果尚未启用),然后将此代码放入 DOCUMENT_ROOT/vic.htaccess
文件:
RewriteEngine On
RewriteBase /vic/
RewriteCond %{THE_REQUEST} \s/+vic/index\.php\?vic=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
RewriteRule ^([0-9]+)/?$ index.php?vic=$1 [L,QSA,NC]