【问题标题】:htaccess with two indexes for localeshtaccess 具有两个用于语言环境的索引
【发布时间】:2023-03-14 13:28:01
【问题描述】:

我正在使用 Reactjs 客户端,并且我有两个索引 index.htmlindexAR.html 我正在为每种语言的 SEO 做一个索引。

网址示例:example.com/ar/{pages}

网址示例:example.com/en/{pages}

所以我需要告诉 HTTP 服务器如果 find ar in URL 返回 indexAR.html 如果还有其他返回 index.html

#.htaccess

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

【问题讨论】:

    标签: reactjs apache .htaccess http mod-rewrite


    【解决方案1】:

    以下列方式保存您的 htaccess 规则文件。确保您的 htaccess 规则文件与 aren 文件夹一起存在(不在其中,除了它们)。

    确保在测试您的 URL 之前清除您的浏览器缓存。

    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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 2015-01-03
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      • 1970-01-01
      相关资源
      最近更新 更多