我尝试将具有特定ID的Joomla插件链接重定向到默认管理页面,如下所示:
当用户在Joomla后端登录时,他可以到达这个插件页面:
https://www.example.com/administrator/index.php?option=com_plugins然后,如果他想打开一个id为422的插件来编辑它,他将点击这个链接:
https://www.example.com/administrator/index.php?option=com_plugins&task=plugin.edit&extension_id=422但是,我不想打开插件,我希望用户被重定向到这个页面:
https://www.example.com/administrator/index.php为了实现这一点,我在文件夹.htaccess中创建了一个administrator,并将代码放在最后。因此,我设置了一系列的插件I,用户无法编辑,但会被重定向。请查找.htaccess文件的所有内容如下:
# Canonical https/www
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# Redirect plug id from 350 to 423:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{QUERY_STRING} (^|&)option\=com_plugins($|&)
RewriteCond %{QUERY_STRING} (^|&)extension_id=\b(3[5-8][0-9]|39[0-9]|4[01][0-9]|42[0-3])\b($|&)
RewriteRule ^administrator/index\.php$ https://www.example.com/administrator/index.php? [L,R=302]
# Redirect plug id from 425 to 10864:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{QUERY_STRING} (^|&)option\=com_plugins($|&)
RewriteCond %{QUERY_STRING} (^|&)extension_id=\b(42[5-9]|4[3-9][0-9]|[5-9][0-9]{2}|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|10[0-7][0-9]{2}|108[0-5][0-9]|1086[0-4])\b($|&)
RewriteRule ^administrator/index\.php$ https://www.example.com/administrator/index.php? [L,R=302]但不起作用。
发布于 2022-10-04 11:08:17
我在文件夹(^|&)extension_id=\b(35-8|390-9|401|420-3)\b($|&)中创建了一个
.htaccess,并将代码放在从350到423的end.Redirect即插即用id处: RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteCond %{QUERY_STRING} (^ RewriteCond &)option\=com_plugins($|&)RewriteCond %{QUERY_STRING} RewriteRule ^管理员/index.php$ https://www.example.com/administrator/index.php? L,R=302
如果.htaccess文件位于/administrator子目录中,则需要从RewriteRule模式的开头删除administrator/ (第一个参数),否则规则将永远不匹配。
在.htaccess中,RewriteRule模式与包含.htaccess文件的目录的相对URL路径匹配。
换句话说,它应该是这样的:
:
RewriteRule ^index\.php$ https://www.example.com/administrator/index.php [QSD,R=302,L]此外,在Apache2.4上,您可以使用QSD (查询字符串丢弃)标志,而不是附加空查询字符串来删除原始查询字符串。
前面与查询字符串和插件id匹配的条件是可以的,应该与请求的URL匹配。(尽管边界\b元素这个词是不必要的。)
根据您拥有的其他指令,此规则应该位于.htaccess文件的顶部,而不是“在末尾”。由于您使用了绝对替换字符串,所以在常规规范重定向之前包含这些规则将是更理想的(尽管这确实假定您没有实现HSTS)。
您还忽略了有关规则中的RewriteEngine On指令。
所以,它应该是这样的:
RewriteEngine On
# Redirect plug id from 350 to 423:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{QUERY_STRING} (^|&)option\=com_plugins($|&)
RewriteCond %{QUERY_STRING} (^|&)extension_id=(3[5-8][0-9]|39[0-9]|4[01][0-9]|42[0-3])($|&)
RewriteRule ^index\.php$ https://www.example.com/administrator/index.php? [QSD,R=302,L]
# Redirect plug id from 425 to 10864:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{QUERY_STRING} (^|&)option\=com_plugins($|&)
RewriteCond %{QUERY_STRING} (^|&)extension_id=(42[5-9]|4[3-9][0-9]|[5-9][0-9]{2}|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|10[0-7][0-9]{2}|108[0-5][0-9]|1086[0-4])($|&)
RewriteRule ^index\.php$ https://www.example.com/administrator/index.php [QSD,R=302,L]
# Canonical https/www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]补充说明:
http://example.com/ (HTTP +non)时重定向的次数。但这确实假设了上面的第一条。REQUEST_URI服务器变量时,不需要遍历和捕获整个URL路径。\b,因为这里似乎没有必要这样做。https://stackoverflow.com/questions/73929597
复制相似问题