.htaccess 重定向并添加变量
我们的客户横幅活动今天启动,但已存入错误的网址。
所以我尝试重定向
website.com/wheels/?lang=en&sel=540
到
website.com/wheels/index.html?lang=en&sel=540
我尝试将 .htaccess 放入包含以下内容的文件夹中:
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/?$ index.html?lang=$1&sel=$2
但它不起作用。有人知道我做错了什么吗?
编辑
我在根目录中发现了一个现有的.htaccess。它包含以下代码:
RewriteEngine On
RewriteBase /
RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/ - [L]
RewriteRule ^typo3$ typo3/index_re.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php [L]
如果我添加以下代码,则不会发生任何事情:
RewriteCond %{QUERY_STRING} ^lang=en&sel=[0-9]+(&|$) [NC]
RewriteRule ^(wheels)/$ /$1/index.html [R=301,L,NC]
顺便说一句,lang 不是静态的,它可以是 en 或 de。
our clients banner campain lauched today an the wrong url has been deposited.
So i try to redirect
website.com/wheels/?lang=en&sel=540
to
website.com/wheels/index.html?lang=en&sel=540
I tryed to put a .htaccess in the folder wheels which contains following:
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/?$ index.html?lang=$1&sel=$2
But it doesn't work. Anyone has an idea, what i'm doing wrong?
EDIT
I found a existing .htaccess in the ROOT. It contains following code:
RewriteEngine On
RewriteBase /
RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/ - [L]
RewriteRule ^typo3$ typo3/index_re.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php [L]
If I add the code folling code, nothing happens:
RewriteCond %{QUERY_STRING} ^lang=en&sel=[0-9]+(&|$) [NC]
RewriteRule ^(wheels)/$ /$1/index.html [R=301,L,NC]
Btw, lang is not static, it can be en or de.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将其添加到网站根目录中的 .htaccess 中。默认情况下携带查询字符串参数。
Try adding this to the .htaccess in the root directory of your website. The querystring parameters are carried through by default.
在您的 ROOT .htaccess 中使用它:
Use this in your ROOT .htaccess:
您还可以通过在现有 RewriteRule 前面添加额外的 RewriteCond 来实现此目的
You could also do this by adding an extra RewriteCond in front of the existing RewriteRule