在没有特定参数的情况下将htaccess重定向到同一页面

时间:2016-01-29 14:33:47

标签: regex .htaccess redirect url-rewriting url-redirection

例如,重定向:

/somepage.php?parameter1=jon&parameter2=3&lang=en&parameter4=5

重定向到:

/somepage.php?parameter1=jon&parameter2=3&parameter4=5

2 个答案:

答案 0 :(得分:1)

此处您可以独立于页面long currentTime = new Date().getTime(); datePickerDialog.getDatePicker().setMinDate(currentTime);

的其他参数删除参数lang
somepage.php

取自Official Apache mod_rewrite Documentation

答案 1 :(得分:0)

试试这个:

RewriteEngine on


RewriteCond %{QUERY_STRING} ^perm1=([^&]+)&perm2=([^&]+)&perm3=([^&]+)&lang=([^&]+)&perm5=([^&]+)$
RewriteRule ^index.php$ /index.php?perm1=%1&perm2=%2&perm3=%3&perm5=%5 [NC,L,R]

另一种选择:

RewriteEngine on


RewriteCond %{THE_REQUEST} /index.php\?perm1=([^&]+)&perm2=([^&]+)&perm3=([^&]+)&lang=([^&]+)&perm5=([^&\s]+) [NC]

RewriteRule ^index.php$ /index.php?perm1=%1&perm2=%2&perm3=%3&perm5=%5 [NC,L,R]