问题原文
原帖链接 · Sahil Moldharia · CC BY-SA 3.0
Is there anything i can use in my htaccess to send 410 code to all the links but not some links ?
Example:
I would like to 410 this urls (List is about 40k links)
www.example.com/c1
www.example.com/c2
www.example.com/c3
www.example.com/c4
www.example.com/g1
www.example.com/g2
www.example.com/g3
www.example.com/g4
and so one....
but this links should not come 410, anything that start with c or g
Like:
www.example.com/categories/
www.example.com/concreate/
www.example.com/colombs/
Right now I am using this code in my .htaccess file but this also giving 410 to above links.
RewriteEngine On
RewriteCond %{QUERY_STRING} c
RewriteRule .* - [G,L]
ErrorDocument 410 default
Any help would be much appreciated.
已采纳解答
原帖链接 · MrWhite · CC BY-SA 3.0
RewriteCond %{QUERY_STRING} c
Not sure why you are referencing the QUERY_STRING here? Your URLs don't appear to contain a query string?
It looks like the URLs you want to block start with a c or g and followed by a digit (I'll assume 1 or more digits). In which case, try something like the following:
RewriteEngine On
RewriteRule ^[cg]\d+$ - [G]
No need for the L flag with G.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
