Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess重定向文件名和扩展名_Php_.htaccess_Var - Fatal编程技术网

Php htaccess重定向文件名和扩展名

Php htaccess重定向文件名和扩展名,php,.htaccess,var,Php,.htaccess,Var,各位早上好 任务是将mysite/images/hotlinked.gif转换为mysite/index.php?i=hotlinked.gif .htaccess整晚都在开车送我去喝咖啡。你能帮我吗 RewriteEngine on RewriteBase / # Redirect direct links to index.php?i=var RewriteRule ^(.+)\.(gif|jpg|png|bmp)$ http://mysite/index.php?i=$1 [L,NC,QS

各位早上好

任务是将
mysite/images/hotlinked.gif
转换为
mysite/index.php?i=hotlinked.gif

.htaccess整晚都在开车送我去喝咖啡。你能帮我吗

RewriteEngine on
RewriteBase /
# Redirect direct links to index.php?i=var
RewriteRule ^(.+)\.(gif|jpg|png|bmp)$ http://mysite/index.php?i=$1 [L,NC,QSA]
返回mysite/index.php?i=hotlinked

没有

另外,如果我用错误的术语搜索,有没有人能把它放到htaccess的行话里,这样我就可以在我的博客上正确地发布修复程序


感谢和节日快乐

$1
替换为
$1.$2
。(或者,我不知道如何编写write.htaccess,我帮助自己用KWrite中支持的正则表达式替换函数)

您在正则表达式中选择了两个引用。无论您在哪里使用()都是在进行新的选择(这过于简化了。有许多示例中,您可以在不希望选择所指定内容的情况下使用括号),并且只将第一个选择传递给查询。要传递第二个参数,需要向查询字符串中添加$2

例如,将
i=$1
更改为
i=$1.$2