1

I want redirect augias.eu to subdirectory augias.eu/fr. Redirection is working fine but all the urls like augias.eu/fr/path are redirected to augias.eu/fr I don't get it. The website is live.

RewriteEngine on RewriteCond %{HTTP_HOST} ^augias.eu [NC,OR] RewriteCond %{HTTP_HOST} ^www.augias.eu [NC] RewriteRule ^(.*)$ https://augias.eu/fr/$1 [L,R=301,NC] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 

HTacces file of the /fr directory

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 
3
  • Do you have any other directives? Any other .htaccess files (perhaps in the /fr subdirectory - if that is a physical subdirectory)? Commented Dec 15, 2021 at 11:38
  • Indeed I edited the post Commented Dec 15, 2021 at 11:43
  • Are you hosting multiple domains? Commented Dec 15, 2021 at 16:42

1 Answer 1

2

In the main directory .htaccess file change this RewriteRule:

RewriteRule ^(.*)$ https://augias.eu/fr/ [L,R=301,NC] 

to this one:

RewriteRule ^(.*)$ https://augias.eu/fr/$1 [L,R=301,NC] 

because $1 represents the first value enclosed in (). In this case match this expression (.*).

And inside the /fr/ folder, edit or create a new .htaccess file with this content:

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase /fr/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /fr/index.php [L] </IfModule> # END WordPress 
Sign up to request clarification or add additional context in comments.

6 Comments

Although, unless there are other directives we are not privy to (eg. another .htaccess file in the /fr subdirectory - if indeed that is a subdirectory - containing mod_rewrite directives) then this will result in a redirect-loop. (Assuming we are not redirecting to an external domain.)
I changed the code with addign $1 but still the same. Deleting the code in the htaccess of the subdirectory created a loop I think. I added in the post the htaccess subdirectory code..
@PaulMartinez: sorry, I did not know that you had another .htacces file in that subfolder containing also a wordpress. I have edited my answer to fit new scenario. Check it please.
@masterguru I thought you solved it. But I think there was just a slightly improvments : I can access to this path augias.eu/fr/le-projet but there is still a redirection on augias.eu/fr/contact , augias.eu/fr/news or all translated pages augias.eu/fr/en . I don't know what to think...
@PaulMartinez mmm... maybe a browser cache problem? It seems to run well from my side right now. Try to clean browser cache or try another browser, please
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.