带参数的 .htaccess链接



我有一个URL如下的页面:https://something.com/paste/log.php?log=H7nSEIPaVr

(顺便说一下,我的主页是:https://something.com/paste/index.php)我想通过像这样给出日志参数来使它工作:https://something.com/paste/H7nSEIPaVr它会重定向到原始url。(或者如果它只给我一个参数会更好- ?log=xxx)

我有一个。htaccess文件,但它不适合我。(重写是启用的,所以htaccess工作正常)

RewriteEngine on
RewriteRule /paste/^([a-zA-Z0-9]*$)/?     /log.php?log=$1    [QSA]

这可能是您正在寻找的规则:

RewriteEngine on
RewriteRule ^/?paste/([a-zA-Z0-9]+)/?$ /paste/log.php?log=$1 [L]

该规则需要在中央http服务器的主机配置中实现。或者,如果您没有访问权限,您可以使用分布式配置文件(通常称为".htaccess"),该文件必须位于http服务器的DOCUMENT_ROOT文件夹中。

另一种选择是将该变体放在/paste文件夹内的分布式文件中:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)/?$ log.php?log=$1 [L]

最新更新