0

我有一个 .htaccess 发送这些网址:

http://example.com/this/is/test/

到 index.php 得到这样的 url:

index.php?var1=this&var2=is&var3=test

我想要做的就是改变/to:意味着 url 将是这样的:

http://example.com/this:is:test

就像以前一样将变量发送到索引页面。这是我的 .htaccess 文件:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/([^/]+)?/?([^/]+)?/?([^/]+)?/?   [NC]
RewriteRule .*     index.php?var1=%1&var2=%2&var3=%3   [L]
4

1 回答 1

1

你不应该%{REQUEST_URI}用来匹配零件。因此,为了制作您想要的东西,您必须将您的更改/:. 我还将使用更好的语法。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([^:]+):([^:]+):([^/]+)/? index.php?var1=$1&var2=$2&var3=$3 [L]
于 2013-01-25T19:34:08.097 回答