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?

1
  • 2
    Just remove / after ^ Commented Feb 25, 2022 at 18:44

1 Answer 1

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] 
Sign up to request clarification or add additional context in comments.

1 Comment

That seems to do the trick. Thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.