Jshop采用前后端分离的架构,当我们的wap端和后端在一起的时候,就会引起路由的冲突,所以,v2.0.6版本之前,前端(uni-app版本)url地址里会加一个#号,但是这个#号在微信公众号里不认识,这就会出现在微信里分享所有的页面,都会跳转到首页的问题。现在我们把#号拿掉了,这时候,就需要对伪静态规则进行修改,规则如下:
nginx中的伪静态配置
location /wap/ {
try_files $uri /wap/index.html;
}
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
apache的伪静态规则,我们默认在/public/.htaccess中有设置
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wap/(.*) /wap/index.html [QSA,PT,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(wap)
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
</IfModule>
如果wap端和后端不在一起的话,可以用默认的tp5.1的伪静态(https://www.kancloud.cn/manual/thinkphp5_1/353955)。
iis伪静态
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="jihainet_wap" stopProcessing="true"> <match url="^wap/(.*)" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="/wap/index.html" appendQueryString="true" /> </rule> <rule name="jihainet" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>