0
你好,我有以下结构http://localhost/index.php?a=$var1&b=var2&c=$var3
htaccess的重写友好的URL
我想,当有人去http://localhost/$var1/$var2/$var3
将其更改为他们被发送出去http://localhost/index.php?a=$var1&b=var2&c=$var3
你好,我有以下结构http://localhost/index.php?a=$var1&b=var2&c=$var3
htaccess的重写友好的URL
我想,当有人去http://localhost/$var1/$var2/$var3
将其更改为他们被发送出去http://localhost/index.php?a=$var1&b=var2&c=$var3
在适当的地方添加这个文档根目录下的htaccess文件。
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+index\.php\?a=([^&]+)&b=([^&]+)&c=([^&\ ]+)
RewriteRule^/%1/%2/%3? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /index.php?a=$1&b=$2&c=$3 [L,QSA]
需要注意的是你改变相对URI的基础,当你有浏览器加载一个/aaa/bbb/ccc
网址,而不是/index.php
。所以,你的链接需要或者是绝对的URL,或者你需要一个基本标记在您的网页标题:
<base href="/" />
如果我想使用3个变量,并使用另一个网络参数A = VAR1。我需要rewritecond吗? – nodejsj