String 如果存在特定字符串,如何从htaccess重定向中删除该字符串?
我有以下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/
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
。