.htaccess-使URL类似于页面:部分
我有一个.htaccess可以发送以下URL:.htaccess-使URL类似于页面:部分,.htaccess,.htaccess,我有一个.htaccess可以发送以下URL: http://example.com/this/is/test/ 要获取如下url的index.php,请执行以下操作: index.php?var1=this&var2=is&var3=test http://example.com/this:is:test 我只想将/更改为:表示url如下: index.php?var1=this&var2=is&var3=test http://example.com/
http://example.com/this/is/test/
要获取如下url的index.php,请执行以下操作:
index.php?var1=this&var2=is&var3=test
http://example.com/this:is:test
我只想将/
更改为:
表示url如下:
index.php?var1=this&var2=is&var3=test
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]
您不应该使用
%{REQUEST\u URI}
来匹配部件。因此,为了得到你想要的,你必须将你的/
更改为:
。我还将使用更好的语法
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([^:]+):([^:]+):([^/]+)/? index.php?var1=$1&var2=$2&var3=$3 [L]