Regex Htaccess重写到特定页面/语言

Regex Htaccess重写到特定页面/语言,regex,apache,.htaccess,codeigniter,mod-rewrite,Regex,Apache,.htaccess,Codeigniter,Mod Rewrite,我试图使重定向侦听到某个域。 我有3个域名; -www.tocdesal.com www.tocdesal.es www.tocdesal.nl 现在我要实现这一点 www.tocdesal.com>www.tocdesal.com/en_GB/ www.tocdesal.nl>www.tocdesal.com/nl_nl/ www.tocdesal.es>www.tocdesal.com/es\es/ 下面是一些我用来管理多语言和禁止人们使用某些文件夹的代码。 我希望有人能在这方面帮助我

我试图使重定向侦听到某个域。 我有3个域名; -www.tocdesal.com

  • www.tocdesal.es

  • www.tocdesal.nl

现在我要实现这一点

www.tocdesal.com>www.tocdesal.com/en_GB/

www.tocdesal.nl>www.tocdesal.com/nl_nl/

www.tocdesal.es>www.tocdesal.com/es\es/

下面是一些我用来管理多语言和禁止人们使用某些文件夹的代码。 我希望有人能在这方面帮助我

<IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On

    # NON-WWW > WWW
    #RewriteCond %{HTTP_HOST} ^www\.tocdesal\.nl [NC]
    #RewriteRule (.*) http://www.tocdesal.nl/nl_NL/home/$1 [R=301,L]

    # CUSTOM REWRITES
    #Redirect 301 /[oldlink] [new-full-link]

    # We dont want snooping people
    Options -Indexes

    #RewriteCond %{REQUEST_URI} ^framework.*

    # If your website begins from a folder e.g localhost/my_project then 
    # you have to change it to: RewriteBase /my_project/
    # If your site begins from the root e.g. example.local/ then
    # let it as it is
    #RewriteBase /tvmoordrecht

    # Protect application and system files from being viewed when the index.php is missing
    RewriteCond $1 ^(framework/modules|framework/coremodules|framework/cicore|application|assets|custommodules)

    # Rewrite to index.php/access_denied/URL
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

    # Allow these directories and files to be displayed directly:
    RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|css|js|images|img|fonts|upload|framework/assets/|themes|framework/apps/elfinder|dev-cmslemonupdater|cmslemonupdater)

    # No rewriting
    RewriteRule ^(.*)$ - [PT,L]

    # Rewrite to index.php/URL
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

#启用URL重写
重新启动发动机
#非WWW>WWW
#重写cond%{HTTP_HOST}^www\.tocdesal\.nl[NC]
#重写规则(.*)http://www.tocdesal.nl/nl_NL/home/$1[R=301,L]
#自定义重写
#重定向301/[oldlink][new full link]
#我们不想窥探别人
选项-索引
#重写cond%{REQUEST_URI}^框架*
#如果您的网站从一个文件夹开始,例如localhost/my_项目,那么
#您必须将其更改为:RewriteBase/my_project/
#如果您的站点从根开始,例如example.local/那么
#随它去吧
#重写基/tvmoordrecht
#当index.php丢失时,保护应用程序和系统文件不被查看
重写第二个$1^(框架/模块|框架/核心模块|框架/核心模块|应用程序|资产|定制模块)
#重写到index.php/access\u denied/URL
重写规则^(.*)$index.php/access_denied/$1[PT,L]
#允许直接显示以下目录和文件:
重写成本$1^(索引\.php | robots\.txt | favicon\.ico | css | js | image | img | font | upload | framework/assets/| themes | framework/apps/elfinder | dev cmslemonupdater | cmslemonupdater)
#不重写
重写规则^(.*)$-[PT,L]
#重写到index.php/URL
重写规则^(.*)$index.php/$1[PT,L]

行上的
重写引擎之后插入这3条规则:

RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.com$ [NC]
RewriteRule !^en_GB/ http://www.tocdesal.com/en_GB%{REQUEST_URI} [NE,R=301,L,NC]

RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.nl$ [NC]
RewriteRule ^ http://www.tocdesal.com/nl_NL%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.es$ [NC]
RewriteRule ^ http://www.tocdesal.com/es_ES%{REQUEST_URI} [NE,R=301,L]

这就是我现在拥有的。非www重定向到标准域(.com)的www,其余重定向到域设置的语言

<IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On

    # Redirects to the page with that language selected

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.nl$ [NC]
    RewriteRule ^ http://www.tocdesal.com/nl_NL%{REQUEST_URI} [NE,R=301,L]

    RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.es$ [NC]
    RewriteRule ^ http://www.tocdesal.com/es_ES%{REQUEST_URI} [NE,R=301,L]

    # CUSTOM REWRITES
    #Redirect 301 /[oldlink] [new-full-link]

    # We dont want snooping people
    Options -Indexes

    #RewriteCond %{REQUEST_URI} ^framework.*

    # If your website begins from a folder e.g localhost/my_project then
    # you have to change it to: RewriteBase /my_project/
    # If your site begins from the root e.g. example.local/ then
    # let it as it is
    #RewriteBase /tvmoordrecht

    # Protect application and system files from being viewed when the index.php is mi
    RewriteCond $1 ^(framework/modules|framework/coremodules|framework/cicore|applica

    # Rewrite to index.php/access_denied/URL
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

    # Allow these directories and files to be displayed directly:
    RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|css|js|images|img|fonts|uplo

    # No rewriting
    RewriteRule ^(.*)$ - [PT,L]

    # Rewrite to index.php/URL
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

#启用URL重写
重新启动发动机
#重定向到选择了该语言的页面
重写cond%{HTTP_HOST}^www\。
重写规则^(.*)$http://www.%{HTTP_HOST}/$1[R=301,L]
RewriteCond%{HTTP_HOST}^(?:www\)?tocdesal\.nl$[NC]
重写规则^http://www.tocdesal.com/nl_NL%{REQUEST_URI}[NE,R=301,L]
RewriteCond%{HTTP_HOST}^(?:www\)?tocdesal\.es$[NC]
重写规则^http://www.tocdesal.com/es_ES%{REQUEST_URI}[NE,R=301,L]
#自定义重写
#重定向301/[oldlink][new full link]
#我们不想窥探别人
选项-索引
#重写cond%{REQUEST_URI}^框架*
#如果您的网站从一个文件夹开始,例如localhost/my_项目,那么
#您必须将其更改为:RewriteBase/my_project/
#如果您的站点从根开始,例如example.local/那么
#随它去吧
#重写基/tvmoordrecht
#当index.php为mi时,保护应用程序和系统文件不被查看
重写第二个$1^(框架/模块|框架/核心模块|框架/核心模块|应用
#重写到index.php/access\u denied/URL
重写规则^(.*)$index.php/access_denied/$1[PT,L]
#允许直接显示以下目录和文件:
重写COND$1^(索引\.php | robots\.txt | favicon\.ico | css | js | image | img | font | uplo
#不重写
重写规则^(.*)$-[PT,L]
#重写到index.php/URL
重写规则^(.*)$index.php/$1[PT,L]

遗憾的是,它不起作用。我仍然得到了无休止的重定向循环。我认为可能是其他行中的问题导致了问题。我没有.htaccess中的maby天赋,你从哪个URL获得循环?.es现在起作用了!太好了!有没有办法让所有域的非www分别转到www.tocdesal.*如果可以的话完成了,我非常高兴anubhava谢谢你这个解决方案只有当我把.com重写放到.com的翻页、翻页和循环中时才起作用。我也把规则放在了3次重写的最后一次,但它没有帮助。它与.com域一起工作不是很重要,那是标准的英文版本。我在e防止循环的第一条规则。