切换语言问题

bug问题 · xiaoming · 于 5年前 发布 · 3017 次阅读

项目刚刚搭建好,英文url是http://www.fecshop.com/ ,中文是http://www.fecshop.com/cn. 在英文地址下没有问题,到了中文的时候导航栏和商品详情链接进去都是404,我想问下问题大概出在什么位置

共收到 19 条回复
xiaoming#25年前 0 个赞

还是报错,url没错了

Fecmall#35年前 0 个赞

原因:

1.查看store部分是否配置好:http://www.fecshop.com/doc/fecshop-guide/develop/cn-1.0/guide-fecshop-about-config.html 第7部分,store的配置 7、配置store的域名

2.nginx配置:

参看:

https://github.com/fecshop/yii2_fecshop_docker/blob/master/services/web/nginx/conf/conf.d/default.conf

91行:

location /cn/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /cn/index.php last;
        }
    }

需要做nginx rewrite设置。

xiaoming#45年前 0 个赞

解决了,谢谢

lp377762984#55年前 0 个赞

@xiaoming 我也遇到这个问题,按照论坛方法都试过了,都没有得到解决,请问一下你怎么解决的。(环境是windows)

lp377762984#65年前 2 个赞

已经解决,大家可以按照我的方法试试。在appfront/web/cn下新建.htaccess文件,文件内容

  <IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
  </IfModule>
Fecmall#75年前 0 个赞

参看这个文章:http://www.fecshop.com/topic/453

Alien#84年前 0 个赞

@lp377762984 [#6楼](#comment6) 我的是 WampServer 环境,遇到了同样的问题,参照您的方法在appfront/web/cn下新建.htaccess文件,成功解决。感谢!🙇‍

Alien#94年前 0 个赞

哎!自从 切换到 2.x 版本后,同样的问题使用同样处理的方法,居然解决不了了,不各位又遇到相同情况吗?难道只能转用nginx了?

Fecmall#104年前 0 个赞

一二版本都是一样的,看六楼的解决

Alien#114年前 0 个赞

@Fecmall [#10楼](#comment10) 不知道,反正之前用(1.7.3 与 1.9.1)时,用的如下配置

  <IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
  </IfModule>

都解决了这个问题;上到2.x后就没用了。


刚换nginx了(系统依旧为windows, 用的Wamp.NET),采用如下配置去index.php,可以正常访问量了

server
{
	listen 127.0.0.1:80;
	server_name appfront.fecshopq.com;
	root "C:/Wamp.NET/manager/public/fecshop/appfront/web/";
	location /
	{
		try_files $uri $uri/ /index.php?$args;
	}
	location ~ \.php$
	{
		fastcgi_pass 127.0.0.1:7120;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include fastcgi_params;
	}

	location ~ /sitemap.xml 
	{   
		if ($host  ~ .*appfront.fecshop.es) {  
			rewrite ^/sitemap\.xml /sitemap_es.xml last;  
		}
	}

	location /fr/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /fr/index.php last;
        }
	}
	
    location /es/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /es/index.php last;
        }
	}

	 location /cn/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /cn/index.php last;
        }
    }

    location /de/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /de/index.php last;
        }
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires      30d;
    }

    location ~ .*\.(js|css)?$ {
        expires      12h;
    }
}

server
{
	listen 127.0.0.1:443 ssl;
	server_name appfront.fecshopq.com;
	root "C:/Wamp.NET/manager/public/fecshop/appfront/web/";
	ssl_certificate "C:/Wamp.NET/bin/6-nginx_1.16.0_x86/conf/vhosts/appfront.fecshopq.com.crt";
	ssl_certificate_key "C:/Wamp.NET/bin/6-nginx_1.16.0_x86/conf/vhosts/appfront.fecshopq.com.key";
	ssl_session_cache shared:SSL:1m;
	ssl_session_timeout 5m;
	ssl_ciphers HIGH:!aNULL:!MD5;
	ssl_prefer_server_ciphers on;
	location /
	{
		try_files $uri $uri/ /index.php?$args;
	}
	location ~ \.php$
	{
		fastcgi_pass 127.0.0.1:7120;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include fastcgi_params;
	}

	location ~ /sitemap.xml 
	{   
		if ($host  ~ .*appfront.fecshop.es) {  
			rewrite ^/sitemap\.xml /sitemap_es.xml last;  
		}
	}

	location /fr/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /fr/index.php last;
        }
	}
	
    location /es/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /es/index.php last;
        }
	}

	 location /cn/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /cn/index.php last;
        }
    }

    location /de/ {
        index index.php;
        if (!-e $request_filename){
            rewrite . /de/index.php last;
        }
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires      30d;
    }

    location ~ .*\.(js|css)?$ {
        expires      12h;
    }
}
Fecmall#124年前 0 个赞

@Alien #11楼

.htaccess 放到@appfront/web/cn,fr等多语言下面配置

Alien#134年前 0 个赞

@Fecmall #12楼 放了的。(“win10 + wampserver” 与 “win10 + wamp.net” 下)已多次测试,确认如下.htaccess配置已无法满足在Fecmall 2.x版本中Apacheindex.php

  <IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
  </IfModule>
Fecmall#144年前 0 个赞

@Alien #13楼 你后台appfront store没有进行配置吧?

Alien#154年前 0 个赞

@Fecmall #14楼 配置了的。【我再描述一下问题吧:各语言的主页(appfront.fecmalltest.comappfront.fecmalltest.com/cnappfront.fecmalltest.com/fr等等 )都可以正常打开,但是,除appfront.fecmalltest.com以外,其他语言主页下所有菜单及商品链接都无法正常打开,会变成2#楼的404页面】

Fecmall#164年前 0 个赞

@Alien #15楼 @Alien #15楼

本地win + apache的等一下吧,我正在出教程

Alien#174年前 0 个赞

@Fecmall #16楼 好的,谢谢!

Alien#194年前 1 个赞

@Fecmall #18楼 感谢!对比了Fecmall 2.1.6版本的权威.htaccess文件,找到了问题。是 http://www.fecmall.com/topic/392 #3楼 RewriteBase /的锅(本质原因还是Alien太菜太粗心了:joy:),去掉RewriteBase /那一行也就正常了。

原来之前在调试Fecmall 1.7.3版本的过程中,不知不觉在fecshop\appfront\webfecshop\appfront\web\cn俩目录中分别用到了两个.htaccess文件,如下:

<IfModule mod_rewrite.c>  
RewriteBase /
RewriteEngine On  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]  
</IfModule>

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>

后来在使用Fecmall 2.x版本时,直接都复制了含RewriteBase /的那个.htaccess文件而导致没有有效去掉index.php.


在此纠正Alien #9、#11、#13、#15 言论,如下.htaccess配置在Fecmall一版本与二版本中都是有效的:

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>

顺便贴出Fecmall 2.1.6版本中的官方权威.htaccess文件

<IfModule mod_rewrite.c>  
RewriteEngine On  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]  
</IfModule>

附:Apache > HTTP Server > Documentation > Version 2.4 > Rewrite > Redirecting and Remapping with mod_rewrite

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics