htaccess with two indexes for locales

Viewed 58

I am using Reactjs client-side, and I have two indexes index.html and indexAR.html I am doing it for SEO for every language make an index.

URL example: example.com/ar/{pages}

URL example: example.com/en/{pages}

so I need to tell the HTTP server if find ar in URL returns indexAR.html if anything else returns index.html

#.htaccess

Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.html?path=$1 [NC,L,QSA]
1 Answers

Have your htaccess rules file in following manner. make sure your htaccess rules file is present along with ar, en folders(not inside them, besides them).

Make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ar indexAR.html [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.html?path=$1 [NC,L,QSA]
Related