Force HTTPS redirect configuration
⚙️ Rule switch
💡 Instructions for use
- It is recommended to enable them in order: first force encrypted jumps, then unify domain names, and finally process the migration of old links; reversing the order can easily lead to multiple jumps or even loops.
- When migrating old links, write two paths in each line, separated by spaces; when generating, the output will be a permanent jump, which is suitable for use after adjusting the URL structure.
- Compression is only meaningful for text content; when caching a static resource for a long time, be sure to ensure that the resource file name carries a content identifier, otherwise users will still use the old file after the update.
- When anti-leeching is turned on, empty sources will be automatically allowed to prevent users from being rejected when opening images directly in the address bar. When filling in the whitelist, just write the domain name and do not include the protocol and path.
Unify plaintext access to the encrypted address to avoid two addresses for the same content.
Judgment conditions
First determine whether the current request is an encryption protocol.
Non-encrypted requests are rewritten in their entirety to encrypted addresses.
path preservation
The original path and query parameters are retained when jumping.
Promotional links with parameters will not lose parameters.
Jump count
Only one jump is made, pointing directly to the encrypted address.
Jumping the domain name first and then the protocol will result in two jumps.
Verification method
Use developer tools to view the response status and final address.
Confirm that the final address protocol is encrypted and the path is consistent.
Things to note
Do not enable forced redirection before the certificate is valid, otherwise an access error will be reported directly.
The subdomain name and main domain name need to confirm whether the certificates are ready respectively.
Do not enable forced redirection before the certificate is ready to avoid direct access errors.
📖 Glossary
- Configuration file
- A valid file placed in the directory and read by the server at each request is used to define the access rules for the directory and its subdirectories. It can take effect without restarting the service.
- rewrite engine
- The module responsible for rewriting the request address according to the rules. The redirection and address beautification functions can only be used after they are enabled. The rules are written in two types of instructions: rewrite conditions and rewrite rules.
- 301 redirect
- The response status of permanent jump tells visitors and the retrieval system that the address has been moved to a new address for a long time, and the weight has been transferred accordingly. It is suitable for use after the URL structure is adjusted.
- 302 redirect
- The response status of temporary jump indicates that the original address will still be restored to use. The retrieval system usually retains the original address without transferring the weight, which is suitable for active pages and temporary maintenance.
- Force encryption jump
- The rule that guides the entire plaintext request to the encrypted address is usually used in conjunction with the conditions for judging the request protocol to avoid duplicate addresses and insecure connections.
- URL normalization
- Unify different ways of writing the same content into one address, such as domain names with or without prefixes, and whether there is a slash at the end, to avoid multiple entries on the same page.
- Content compression
- The server compresses the text content before returning it, and the browser decompresses it, which significantly reduces the transmission volume. Images and videos are inherently compressed, and compressing them has no benefit and may be counterproductive.
- browser cache
- Tell the browser to save the resource for a period of time through the response header, and use the local copy directly on the next visit. Static resources are suitable for long caching, and the page itself should be short cached or not cached.
- cache fingerprint
- Add a tag that changes with the content in the resource file name so that the URL will change after the content is updated. In this way, even if a long cache time is set, users can get the new version in time.
- Anti-hotlinking
- Restrict other sites to directly reference your images or files. Only requests from this site or whitelisted domains are allowed to access, reducing bandwidth usage.
- Error page customization
- Replace the server's default error message with a page of your own design, which not only keeps the look and feel of the site consistent, but also guides visitors back to a valid path.
- directory listing
- A list of files automatically listed by the server when there is no default homepage in the directory. Turning it off prevents the directory structure from being browsed by outsiders and is a basic security setting.
🔗 All keywords and tutorials
❓ FAQ
- Will links with parameters lose parameters?
- No, the original path and query parameters are retained when jumping.
- Will there be two jumps?
- According to this rule, it only jumps once. Unifying the domain name first and then unifying the protocol will easily cause it to jump twice.