Mobile app version of vmapp.org
Login or Join
Hamaas447

: Send "410 Gone" response for URLs that are a "c" or "g" followed by digits Is there anything i can use in my htaccess to send 410 code to all the links but not some links ? Example: I

@Hamaas447

Posted in: #410Gone #Htaccess #ModRewrite

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)
example.com/c1 www.example.com/c2 example.com/c3 www.example.com/c4 example.com/g1 www.example.com/g2 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:
example.com/categories/ www.example.com/concreate/ 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Hamaas447

2 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

user82217 provided a fine solution using mod_rewrite. You can also use mod_alias to do it:

RedirectMatch gone "/[cg]d+$"

10% popularity Vote Up Vote Down


 

@Ogunnowo487

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme