You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置GoDaddy主机,让根目录指向public_html/production目录?

Absolutely, there are a few straightforward ways to make your site accessible at example.com/index.php instead of needing the /production subdirectory. Let’s walk through the most reliable options for GoDaddy hosting:

Option 1: Change Your Document Root (Cleanest Solution)

This is the most direct approach—you’ll tell GoDaddy to serve files directly from your production folder instead of the default public_html root. Here’s how:

  1. Log into your GoDaddy Hosting Control Panel.
  2. Navigate to your domain’s settings (look for "Manage" next to your domain, or go to "Web Hosting" > "Manage" > "Settings").
  3. Find the Document Root option (usually under "Domain" or "Advanced Settings").
  4. Update the path from public_html to public_html/production and save changes.

Important Note:

After changing the document root, double-check the path to your database connection file in index.php. Since your site’s root is now production, you’ll need to adjust the include path to point up one directory:

// Before:
// include 'includes/conection_DB.php';

// After:
include '../includes/conection_DB.php';

This ensures your index.php can still find the conection_DB.php file in the public_html/includes folder.

Option 2: Use .htaccess Rewrite Rules (No Document Root Changes Needed)

If you can’t or don’t want to modify the document root, you can use an .htaccess file to silently redirect traffic from example.com/* to example.com/production/*. Here’s how:

  1. Create or edit the .htaccess file in your public_html folder (if it doesn’t exist, just create a new plain text file named .htaccess).
  2. Add these lines:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/production/
RewriteRule ^(.*)$ /production/$1 [L]
  1. Save the file and upload it to your public_html directory if you edited it locally.

How This Works:

  • RewriteEngine On enables URL rewriting.
  • RewriteCond %{REQUEST_URI} !^/production/ makes sure we don’t redirect requests that already go to /production (to avoid loops).
  • RewriteRule ^(.*)$ /production/$1 [L] takes any request to example.com/anything and serves the corresponding file from example.com/production/anything, while keeping the original URL visible.

Option 3: Move Your Files (Quick for Simple Projects)

If your production folder only has index.php and no other assets (like CSS, JS, or images), you can just move the file to the public_html root:

  1. Move public_html/production/index.php to public_html/index.php.
  2. Update the include path in the moved index.php to point directly to the includes folder (since it’s now in the same root as includes):
// Before:
// include '../includes/conection_DB.php';

// After:
include 'includes/conection_DB.php';

Warning: If your production folder has other files (like assets), you’ll need to move those too or update all their paths in your code—this can get messy for larger projects, so we don’t recommend this unless your setup is super simple.


内容的提问来源于stack exchange,提问作者Isaac Hernández Cabrera

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:03:56