如何使用cPanel文件管理器重定向主页?含example.com.sg路径跳转咨询
Hey Bryce, great questions—let’s walk through exactly how to set up that homepage redirect using cPanel’s File Manager, including your specific use case.
First, I’ll cover the general process, then dive into your exact scenario of redirecting example.com.sg to example.com.sg/test.
Step 1: Access cPanel’s File Manager
- Log into your cPanel account (usually via
yourdomain.com/cpanelor your hosting provider’s customer dashboard). - Scroll to the Files section and click File Manager.
- Make sure you’re in your site’s root directory—this is almost always the
public_htmlfolder. You can confirm by checking the path at the top of the File Manager window.
Step 2: Locate or Create the .htaccess File
We’ll use the .htaccess file to add our redirect rule. Here’s how to find it:
- If you don’t see
.htaccessin the root folder:- Hit the Settings button in the top-right corner.
- Check the box for "Show Hidden Files (dotfiles)" and click Save. Now
.htaccessshould appear.
- Right-click on
.htaccessand select Edit (or click the Edit icon at the top). A pop-up might ask about encoding—just click Edit again to proceed.
Step 3: Add the Redirect Rule (Your Specific Case)
To redirect your main domain example.com.sg directly to the /test subdirectory, add this line near the top of your .htaccess file (before any existing rules):
RedirectMatch ^/$ /test/
Let me break this down:
RedirectMatchuses regex to target specific URLs.^/$matches exactly the root URL (your homepage:example.com.sg/)./test/is the path you want to redirect visitors to.
Permanent Redirect for SEO
If you want this to be a permanent redirect (ideal for search engine optimization, as it passes link equity), add the 301 status code like this:
RedirectMatch 301 ^/$ /test/
Step 4: Save and Test
- Click Save Changes in the top-right of the editor.
- Close the editor, then open an incognito window and visit
example.com.sg—you should land directly onexample.com.sg/test.
Quick Troubleshooting
- If the redirect isn’t working: Double-check the rule for typos, and make sure there are no conflicting rules in your
.htaccessfile. - If you accidentally break your site: Just go back to File Manager, edit
.htaccess, and remove the rule you added—it’ll revert to normal.
内容的提问来源于stack exchange,提问作者Bryce

