Home
Support Forums

The site can't access after added redirect rules

I added redirect rule below,it works.But we can’t access the site from all other countries.
redirect rule:

Redirect users in china to /www.baidu.com

/ https://www.baidu.com 302 Country=CN

My site:
https://mythtest.netlify.app/

Please help me

The error:

Hi @sam886

If you remove the rule, can you access the site?

Hi,Nice to meet you.
If I annotated the rule,we still can’t access the site.
See below:

Redirect users in china to /www.baidu.com

#/ https://www.baidu.com 302 Country=CN

Why?

I am unable to test what happens with redirects from China as I don’t have VPN access there.

However, using a VPN location in the US I was able to use

/    https://www.google.us    302!    Country=US

I have then accessed the same domain from other locations as was not redirected, and page loaded correctly.

Note: I have used a ! to force the redirect, even if content is in at that URL.

If you cannot access your site after removing the rule please have a read over

1 Like

Sorry,I still don’t know how to fix it.
By the way,I just wann to block users from China.Could you tell me what shoud I do?

Curious why would need/want to block Chinese users.

If you tell me what you have done (or show me if you can share your public git repository) then I can possibly assist in providing the appropriate steps to fix your issue.

(I do see your site no longer returns a Page Not Found.)

Because I have remove the rediect file,but now I have added it.The problem happened again,please check.
And can you check the issue through the deploy log?

I doubt the deploy log will give any useful information, but if you share it I can have a look.

Better option is for you to share you git repository so I can test it myself and advise on a solution.

2:44:56 PM: Waiting for other deploys from your team to complete. Check the queue: Netlify App
2:46:56 PM: Build ready to start
2:46:58 PM: build-image version: dd2f6d8803393d46ac35a4f752a5a46f254c0300
2:46:58 PM: build-image tag: v3.9.1
2:46:58 PM: buildbot version: 39428daf62968de16b6279e22b981b8b656d5e02
2:46:58 PM: Building without cache
2:46:58 PM: Starting to prepare the repo for build
2:46:58 PM: No cached dependencies found. Cloning fresh repo
2:46:58 PM: git clone https://github.com/tmac2yt/myth
2:47:01 PM: Preparing Git Reference refs/heads/test
2:47:02 PM: Parsing package.json dependencies
2:47:02 PM: Starting build script
2:47:02 PM: Installing dependencies
2:47:02 PM: Python version set to 2.7
2:47:04 PM: v12.18.0 is already installed.
2:47:05 PM: Now using node v12.18.0 (npm v6.14.4)
2:47:05 PM: Started restoring cached build plugins
2:47:05 PM: Finished restoring cached build plugins
2:47:05 PM: Attempting ruby version 2.7.2, read from environment
2:47:07 PM: Using ruby version 2.7.2
2:47:07 PM: Using PHP version 5.6
2:47:07 PM: Started restoring cached yarn cache
2:47:07 PM: Finished restoring cached yarn cache
2:47:07 PM: Installing yarn at version 1.22.10
2:47:07 PM: Installing Yarn!
2:47:07 PM: > Downloading tarball…
2:47:07 PM: [1/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz β†’ /tmp/yarn.tar.gz.3bwHfTdpXG
2:47:07 PM: % Total % Received % Xferd Average Speed Time Time Time Current
2:47:07 PM: Dload Upload Total Spent Left Speed
2:47:07 PM: 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
2:47:07 PM: 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
2:47:07 PM: 100 81 100 81 0 0 372 0 --:–:-- --:–:-- --:–:-- 371
2:47:08 PM: 100 95 100 95 0 0 155 0 --:–:-- --:–:-- --:–:-- 155
2:47:08 PM: 100 626 100 626 0 0 712 0 --:–:-- --:–:-- --:–:-- 712
2:47:08 PM: 26 1215k 26 320k 0 0 290k 0 0:00:04 0:00:01 0:00:03 290k
2:47:08 PM: 100 1215k 100 1215k 0 0 1082k 0 0:00:01 0:00:01 --:–:-- 41.6M
2:47:08 PM: [2/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz.asc β†’ /tmp/yarn.tar.gz.3bwHfTdpXG.asc
2:47:08 PM: 100 85 100 85 0 0 1937 0 --:–:-- --:–:-- --:–:-- 1937
2:47:08 PM: 100 99 100 99 0 0 1336 0 --:–:-- --:–:-- --:–:-- 1336
2:47:08 PM: 100 630 100 630 0 0 6248 0 --:–:-- --:–:-- --:–:-- 6248
2:47:08 PM: 100 832 100 832 0 0 7430 0 --:–:-- --:–:-- --:–:-- 7430
2:47:08 PM: > Verifying integrity…
2:47:08 PM: gpg: Signature made Fri 02 Oct 2020 11:17:27 AM UTC using RSA key ID 69475BAA
2:47:08 PM: gpg: Good signature from β€œYarn Packaging yarn@dan.cx”
2:47:08 PM: gpg: WARNING: This key is not certified with a trusted signature!
2:47:08 PM: gpg: There is no indication that the signature belongs to the owner.
2:47:08 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907 BBB7 1646 B01B 86E5 0310
2:47:08 PM: Subkey fingerprint: 6D98 490C 6F1A CDDD 448E 4595 4F77 6793 6947 5BAA
2:47:08 PM: > GPG signature looks good
2:47:08 PM: > Extracting to ~/.yarn…
2:47:08 PM: > Adding to $PATH…
2:47:09 PM: > Successfully installed Yarn 1.22.10! Please open another terminal where the yarn command will now be available.
2:47:09 PM: No yarn workspaces detected
2:47:09 PM: Started restoring cached node modules
2:47:09 PM: Finished restoring cached node modules
2:47:10 PM: Installing NPM modules using Yarn version 1.22.10
2:47:10 PM: yarn install v1.22.10
2:47:10 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
2:47:10 PM: [1/4] Resolving packages…
2:47:11 PM: [2/4] Fetching packages…
2:47:58 PM: info There appears to be trouble with your network connection. Retrying…
2:48:01 PM: info fsevents@2.1.2: The platform β€œlinux” is incompatible with this module.
2:48:01 PM: info β€œfsevents@2.1.2” is an optional dependency and failed compatibility check. Excluding it from installation.
2:48:01 PM: info fsevents@1.2.12: The platform β€œlinux” is incompatible with this module.
2:48:01 PM: info β€œfsevents@1.2.12” is an optional dependency and failed compatibility check. Excluding it from installation.
2:48:01 PM: [3/4] Linking dependencies…
2:48:01 PM: warning " > @testing-library/user-event@7.2.1" has unmet peer dependency β€œ@testing-library/dom@>=5”.
2:48:01 PM: warning β€œantd > rc-picker@2.5.10” has unmet peer dependency β€œdayjs@^1.8.30”.
2:48:01 PM: warning " > mobx-react@6.3.0" has incorrect peer dependency β€œmobx@^5.15.4 || ^4.15.4”.
2:48:01 PM: warning β€œmobx-react > mobx-react-lite@2.2.2” has incorrect peer dependency β€œmobx@^4.0.0 || ^5.0.0”.
2:48:01 PM: warning β€œcraco-less > less-loader@6.2.0” has unmet peer dependency β€œwebpack@^4.0.0 || ^5.0.0”.
2:48:28 PM: [4/4] Building fresh packages…
2:48:30 PM: Done in 79.26s.
2:48:30 PM: NPM modules installed using Yarn
2:48:30 PM: Started restoring cached go cache
2:48:30 PM: Finished restoring cached go cache
2:48:30 PM: go version go1.14.4 linux/amd64
2:48:30 PM: go version go1.14.4 linux/amd64
2:48:30 PM: Installing missing commands
2:48:30 PM: Verify run directory
2:48:32 PM: ​
2:48:32 PM: ────────────────────────────────────────────────────────────────
2:48:32 PM: Netlify Build
2:48:32 PM: ────────────────────────────────────────────────────────────────
2:48:32 PM: ​
2:48:32 PM: ❯ Version
2:48:32 PM: @netlify/build 18.13.11
2:48:32 PM: ​
2:48:32 PM: ❯ Flags
2:48:32 PM: baseRelDir: true
2:48:32 PM: buildId: 61613a689d810497afd8b33a
2:48:32 PM: deployId: 61613a689d810497afd8b33c
2:48:32 PM: ​
2:48:32 PM: ❯ Current directory
2:48:32 PM: /opt/build/repo
2:48:32 PM: ​
2:48:32 PM: ❯ Config file
2:48:32 PM: No config file was defined: using default values.
2:48:32 PM: ​
2:48:32 PM: ❯ Context
2:48:32 PM: production
2:48:32 PM: ​
2:48:32 PM: ────────────────────────────────────────────────────────────────
2:48:32 PM: 1. Build command from Netlify app
2:48:32 PM: ────────────────────────────────────────────────────────────────
2:48:32 PM: ​
2:48:32 PM: $ yarn build:testnet
2:48:32 PM: yarn run v1.22.10
2:48:32 PM: $ env-cmd -f .env.testnet craco build
2:48:34 PM: Creating an optimized production build…
2:48:37 PM: Browserslist: caniuse-lite is outdated. Please run the following command: npx browserslist --update-db
2:51:33 PM: Compiled successfully.
2:51:33 PM:
2:51:33 PM: File sizes after gzip:
2:51:34 PM: 798.41 KB build/static/js/2.3477607a.chunk.js
2:51:34 PM: 78 KB build/static/js/main.d9797218.chunk.js
2:51:34 PM: 71.8 KB build/static/css/main.f1bcb320.chunk.css
2:51:34 PM: 772 B build/static/js/runtime-main.83c3e0c4.js
2:51:34 PM: The project was built assuming it is hosted at /.
2:51:34 PM: You can control this with the homepage field in your package.json.
2:51:34 PM: The build folder is ready to be deployed.
2:51:34 PM: You may serve it with a static server:
2:51:34 PM: yarn global add serve
2:51:34 PM: serve -s build
2:51:34 PM: Find out more about deployment here:
2:51:34 PM: bit.ly/CRA-deploy
2:51:35 PM: Done in 183.05s.
2:51:35 PM: ​
2:51:35 PM: (build.command completed in 3m 3.3s)
2:51:35 PM: ​
2:51:35 PM: ────────────────────────────────────────────────────────────────
2:51:35 PM: 2. Deploy site
2:51:35 PM: ────────────────────────────────────────────────────────────────
2:51:35 PM: ​
2:51:35 PM: Starting to deploy site from β€˜netlify-build’
2:51:35 PM: Creating deploy tree
2:51:35 PM: Creating deploy upload records
2:51:35 PM: 0 new files to upload
2:51:35 PM: 0 new functions to upload
2:51:35 PM: Site deploy was successfully initiated
2:51:35 PM: ​
2:51:35 PM: (Deploy site completed in 127ms)
2:51:35 PM: ​
2:51:35 PM: ────────────────────────────────────────────────────────────────
2:51:35 PM: Starting post processing
2:51:35 PM: Post processing - HTML
2:51:35 PM: Post processing - header rules
2:51:35 PM: Netlify Build Complete
2:51:35 PM: ────────────────────────────────────────────────────────────────
2:51:35 PM: ​
2:51:35 PM: (Netlify Build completed in 3m 3.5s)
2:51:36 PM: Post processing - redirect rules
2:51:36 PM: Post processing done
2:51:36 PM: Caching artifacts
2:51:36 PM: Started saving node modules
2:51:36 PM: Finished saving node modules
2:51:36 PM: Started saving build plugins
2:51:36 PM: Site is live :sparkles:
2:51:36 PM: Finished saving build plugins
2:51:36 PM: Started saving yarn cache
2:51:46 PM: Finished saving yarn cache
2:51:46 PM: Started saving pip cache
2:51:46 PM: Finished saving pip cache
2:51:46 PM: Started saving emacs cask dependencies
2:51:46 PM: Finished saving emacs cask dependencies
2:51:46 PM: Started saving maven dependencies
2:51:46 PM: Finished saving maven dependencies
2:51:46 PM: Started saving boot dependencies
2:51:47 PM: Finished saving boot dependencies
2:51:47 PM: Started saving rust rustup cache
2:51:47 PM: Finished saving rust rustup cache
2:51:47 PM: Started saving go dependencies
2:51:47 PM: Finished saving go dependencies
2:51:50 PM: Build script success
2:52:46 PM: Finished processing build request in 5m48.269484064s


https://61613a689d810497afd8b33c--mythtest.netlify.app

If you download the deployed files, does everything look as it should?

Perhaps try downloading a deploy that has worked, and one that has not, to compare the files.

Processing: deploy-61613a689d810497afd8b33c.zip…

Hi @sam886,

Looks like you forgot to link the file.


The error one only has _redirect file

That explains it. You need to upload all the previous files with the new/changed files. You’re only uploading the _redirects file thus the issue.

Thanks,Let me try it again


Now the site can access,but redirect don’t work

https://6161a164c2d4cd0008135f32--mythtest.netlify.app

Please help me check the issue

The redirect needs to be forced:

/ https://www.baidu.com 302! Country=CN

That exclamation mark is important.

It works.Thank you very much