Redirecting Requests
Redirection Overview
When using static website hosting, you can configure redirection to redirect specific or all requests.
If the structure, address, or file name extension of a website is changed, users will fail to access the website using the old address (such as the address saved in the folder of favorites), and the 404 error message is returned. In this case, you can configure redirection for the website to redirect user access requests to a specified page rather than a 404 error page.
Typical scenarios include:
- Redirecting all requests to another website.
- Redirecting specific requests based on redirection rules.
Prerequisites
Web page files required for static website hosting have been uploaded to the specified bucket.
The static website files hosted in the bucket are accessible to all users.
Static web page files in the Archiveor Deep Archive storage class have been restored. For more information, see Restoring Archive or Deep Archive Objects.
Procedure
- In the navigation pane of OBS Console, choose Object Storage.
- In the bucket list, click the bucket you want to operate. The Objects page is displayed.
- In the navigation pane, choose Overview.
- In the Basic Configurations area, click Static Website Hosting. The Static Website Hosting page is displayed.
Alternatively, you can choose Basic Configurations > Static Website Hosting from the navigation pane on the left.
- Click Configure Static Website Hosting. The Configure Static Website Hosting dialog box is displayed.
- Enable Status.
- Set Hosting Type to Redirect requests, as shown in Figure 1. In the text box of Redirect To, enter the bucket's access domain name or URL.
- Click OK.
- In the bucket list, click the bucket to which requests for the static website are redirected.
- (Optional) If the static website files in the bucket are not accessible to everyone, perform this step. If they are already accessible to everyone, skip this step.
To grant required permissions, see Granting All Accounts Read Permission for Specified Objects.
If the bucket contains only static website files, configure the Object Read-Only policy for the bucket, so that all files in it are publicly accessible.
- Choose Permissions > Bucket Policies.
- Click Create.
- Configure bucket policy information.
Figure 2 Granting the Object Read-Only permission
Table 1 Parameters for configuring a public read policy Parameter
Description
Configuration method
Visual Editor and JSON are available. The visual editor is used here. For details about configurations in the JSON view, see Creating a Custom Bucket Policy (JSON View).
Policy Name
Enter a custom policy name.
Policy content
Effect
Select Allow.
Principals
Select All accounts.
Resources
- Select Specified objects.
- Set the resource path to * (indicating all objects in the bucket).
Actions
- Choose Use a template.
- Select Object Read-Only.
- Click Create. The bucket policy is created.
- Verification: Input the access domain name of the bucket in the web browser and press Enter. The bucket or URL to which requests are redirected will be displayed.
In some conditions, you may need to clear the browser cache before the expected results are displayed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot