1

My website has more languages and I want to do this redirect for every languages for example: /es/ to /es, simple with Redirect but this method make problems for subpages, how can I tell htaccess to use this rule only for homepage?

1 Answer 1

0

Assuming that the homepage is the page url: index.php, you'd use:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(en|es|de|hi|jp|zh|...)/(index\.php)?$ [NC]
RewriteRule ^ /%1 [R=301,L]

If you do not want to use mod_rewrite and would prefer a mod_alias solution, try:

RedirectMatch 301 "/(en|es|de|hi|jp|zh|...)/(index\.php)?$" /$1

Please note that I'm not much familiar with mod_alias, so the latter might not work right away. If so, do inform me with a comment here along with the request line from apache's access_log.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .