2

I have this site: neotel2000.com that works this way:

  • Spanish language: neotel2000.com
  • English language: neotel2000.com/en/
  • French language: neotel2000.com/fr/

OK.

I need this:

I want that every possible section relative to the French version (/fr/), it will redirect (301) to the root domain (neotel2000.com). Example:

neotel2000.com/fr/whatever/ -----> neotel2000.com

Although, there are some exceptions (i.e. there are 7 urls relatives to /fr/ where the 301 redirect should not apply) I'll show you one of these url exceptions:

https://www.neotel2000.com/fr/standard-virtuel/

So far I´ve searched dozens of psots here and other forums with no luck.

Here my .htaccess file:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} !^GET\ ./https://www.neotel2000.com/fr/.*\ HTTP
RewriteCond %{THE_REQUEST} !^GET\ ./https://www.neotel2000.com/fr/standard-virtuel/.*\ HTTP
RewriteRule ^fr(.+)/ / [R=301,L]
</IfModule>

Thank you loads

Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
Josea
  • 21
  • 2

1 Answers1

1

You can use this rule

RewriteCond %{REQUEST_URI} !^/fr/(standard-virtuel|example2|example3)/ [NC]
RewriteRule ^fr(/.*)?$ / [R=301,L]

Just replace example2, example3, ... by what you want, each one separated by |

Or, if you prefer the longest version (not condensated), where each condition is for a specific url

RewriteCond %{REQUEST_URI} !^/fr/standard-virtuel/ [NC]
RewriteCond %{REQUEST_URI} !^/fr/example2/ [NC]
RewriteCond %{REQUEST_URI} !^/fr/example3/ [NC]
RewriteRule ^fr(/.*)?$ / [R=301,L]
Justin Iurman
  • 18,954
  • 3
  • 35
  • 54
  • It did not work. Neither the first nor the second rule. Any other suggestions? Thank you – Josea Jul 16 '18 at 09:49
  • Well, it should. The problem must lies elsewhere. Make sure that `mod_rewrite` is enabled and `.htaccess` files allowed. Also, do you have other rules ? Do you use a CMS or is it a custom website ? – Justin Iurman Jul 16 '18 at 10:26
  • Also, it seems to be working as expected on your website. Just tried `/fr/standard-virtuel/` and it is available, while `/fr/whatever/` is being redirected to home. If you don't see the same result, try clearing your browser cache and try again – Justin Iurman Jul 16 '18 at 10:29
  • "Make sure that mod_rewrite is enabled" <- It is enabled. ".htaccess files allowed" <- It is all correct here. – Josea Jul 16 '18 at 11:52
  • Here you have my all of my rules: # Options +FollowSymlinks # RewriteEngine On RewriteBase / # RewriteCond %{REQUEST_URI} !^/fr/(standard-virtuel|https://www.neotel2000.com/fr/les-cloud-call-center-permettent-aux-entreprises-deconomiser-largent-et-beaucoup/)/ [NC] RewriteRule ^fr(/.*)?$ / [R=301,L] – Josea Jul 16 '18 at 12:00
  • "Do you use a CMS or is it a custom website ?" <- WordPress "Also, it seems to be working as expected on your website. Just tried /fr/standard-virtuel/ and it is available, while /fr/whatever/ is being redirected to home. If you don't see the same result, try clearing your browser cache and try again" <- Really weird. But try now if you don't mind. I already cleared cache in both, WordPress and CDN. – Josea Jul 16 '18 at 12:03
  • Your rule syntax is wrong. From your 2-exceptions rule example, it should be `RewriteCond %{REQUEST_URI} !^/fr/(standard-virtuel|les-cloud-call-center-permettent-aux-entreprises-deconomiser-largent-et-beaucoup)/ [NC]`. Since your exception links seem big, feel free to use second solution for readability. Also, from my experience with WordPress, it can quickly become a mess when trying to rewrite with htaccess instead of using its built-in rewrite system. – Justin Iurman Jul 16 '18 at 15:23