Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
String 如果存在特定字符串,如何从htaccess重定向中删除该字符串?_String_.htaccess_Url Rewriting_Url Redirection - Fatal编程技术网

String 如果存在特定字符串,如何从htaccess重定向中删除该字符串?

String 如果存在特定字符串,如何从htaccess重定向中删除该字符串?,string,.htaccess,url-rewriting,url-redirection,String,.htaccess,Url Rewriting,Url Redirection,我有以下htaccess代码: RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC] RewriteCond %{HTTP_REFERER} !mysitee\.com [NC] RewriteRule ([^/]*)\.(jpg|gif|png)$ http://mysitee.com/?attachment=$1 [NC] 这带来的变化是: http://mysitee.com/wp-content/uploads/2015/

我有以下htaccess代码:

RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC] 
RewriteCond %{HTTP_REFERER} !mysitee\.com [NC]
RewriteRule ([^/]*)\.(jpg|gif|png)$ http://mysitee.com/?attachment=$1 [NC]
这带来的变化是:

http://mysitee.com/wp-content/uploads/2015/10/my-image.jpg
为此:

http://mysitee.com/?attachment=my-image

代码运行得很好,但有时会出现以下url:

http://mysitee.com/wp-content/uploads/2015/10/my-image-750x500.jpg
导致

http://mysitee.com/?attachment=my-image-750x500
但我希望它删除“-750x500”以永远不会在重写的url中显示它


请帮助,谢谢

可能的参数是什么?只有
700x500
或可以是任何数字?在原始URL中,您有
700-500
-这是打字错误吗?可能是数字和字母,关键是我希望能够从该代码中的URL中明确删除我定义的任何内容,例如
-750x500
。在本例中,它将是数字和字母,并且您不能仅去除数字,因为这些数字也可能包含在文件名的其他位置,例如
my7-image0x-321x987.jpg
,在其中我希望从文件名中提取并删除
-321x987