不带WWW前缀的域名无法显示博客,如何实现重定向?
Hey there! Let’s sort out that annoying non-www to www redirect issue for your blog. Depending on how your server and domain are set up, here are several solid solutions you can try:
Most domain registrars offer a built-in URL forwarding feature. Here’s how it generally works:
- Log into your domain registrar’s dashboard (where you bought
futuristiccreativity.tk) - Look for "URL Forwarding" or "Domain Redirect" settings
- Set the non-www domain (
futuristiccreativity.tk) to forward permanently (301) tohttp://www.futuristiccreativity.tk - Save the changes—this usually takes a few minutes to propagate across DNS servers
Pro tip: Always use a 301 redirect here, not 302. It tells search engines the non-www domain is permanently moved to the www version, which helps preserve your SEO rankings.
If your blog is hosted on an Nginx server, add this server block to your Nginx config file (usually located at /etc/nginx/nginx.conf or in /etc/nginx/sites-available/):
server { listen 80; server_name futuristiccreativity.tk; # Redirect non-www to www with 301 permanent redirect return 301 $scheme://www.futuristiccreativity.tk$request_uri; }
After adding this, test the config with nginx -t to make sure there are no syntax errors, then reload Nginx with systemctl reload nginx (on Linux systems). The $scheme variable automatically uses HTTP or HTTPS, and $request_uri preserves the original page path so users don’t land on the wrong page.
For Apache servers, first make sure the mod_rewrite module is enabled. Then edit your site’s .htaccess file (usually in your blog’s root directory) and add these lines:
RewriteEngine On # Check if the request is coming from the non-www domain RewriteCond %{HTTP_HOST} ^futuristiccreativity.tk [NC] # Redirect all requests to the www version with 301 RewriteRule ^(.*)$ http://www.futuristiccreativity.tk/$1 [L,R=301]
Save the file, and Apache will apply the changes immediately. The [NC] flag makes the condition case-insensitive, [L] tells Apache this is the last rule to process, and [R=301] specifies the permanent redirect.
If your blog is built on a content management system (CMS) like WordPress:
- Log into your WordPress admin dashboard
- Go to Settings > General
- Update both the WordPress Address (URL) and Site Address (URL) to
http://www.futuristiccreativity.tk - Save your changes—WordPress will automatically handle the redirect for you. If you still run into issues, combine this with the Apache/Nginx config above for extra reliability.
内容的提问来源于Stack Exchange,提问作者Hanu babbar

