1

I'm trying to set all EN pages of a website to the statuscode 410. The URLs look like this:

https://example.com/en/terms-and-conditions/
https://example.com/en/sitemap/
https://example.com/en/category/page-1/
https://example.com/en/category/page-2/
https://example.com/en/category/page-3/subpage-1/

I tried different things, but none worked:

RewriteEngine On
RewriteRule ^/en(/.*)?$  - [G,NC]

this also didn't work:

RewriteEngine On
RewriteRule ^/en(.*)$ - [NC,R=410,L]

What am I doing wrong?

TheKidsWantDjent
  • 1,179
  • 1
  • 9
  • 20

1 Answers1

2

When rewrite rules are used in .htaccess the URL path doesn't start with / because that is the current "base" for the rewrite rules. This is different that when rewrite rules are used in Apache's .conf files where the path does start with /.

I recommend writing rules that can be used in either place by making the starting slash optional. You just need to add a ? after the starting slash:

RewriteEngine On
RewriteRule ^/?en(/.*)?$  - [G,NC]
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109