我正在从子文件夹重定向到子域。这项工作正常,但我想在网址末尾附加一个查询字符串,以跟踪有多少人被重定向。
RewriteRule ^/my-folder/(.*)$ https://subdomain.example.com/?ref=my_ref [R=302,L]
上面应该按照本文的要求工作,但事实并非如此。
它只是将我重定向到 https://subdomain.example.com/
如何?ref=my_ref
在重定向期间添加?
编辑:完整的.htaccess
#to remove old /forum/topic and keep /topic
RewriteRule ^forum/topic/(.*)$ /topic/$1 [L,NC,R=301]
### Rewrites Engine
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]
RewriteRule ^/my-folder/(.*)/?$ https://subdomain.example.com/?ref=$1 [R=302,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
使用您显示的示例,您可以尝试以下操作。希望您正在寻找这个。在测试URL之前,请清除浏览器缓存。
### Rewrites Engine
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^my-folder/(.*)/?$ https://subdomain.example.com/?ref=your_string [R=302,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句