9

我遇到了一个问题,即我的虚拟主机没有出现提供插件域。

我目前有一个指向我的名称服务器的域名。

我进入 cPanel 添加一个指向子目录的插件域,但 cPanel 中可用的只是将域停放在文档根目录“public_html/”。

所以来自停放域的流量会得到错误的内容,这显然是不好的。

我觉得这是不可能的,但我可以将停放的域文档根从 'public_html/' 更改为 'public_html/sub-directory' 吗?

或者也许我可以编辑 .htaccess 文件以将流量从停放域重定向到子目录?

基本上我想要这个地址;www.parked-domain.com/

显示该子目录的内容;www.first-domain.com/parked-directory

我希望这是可能的,否则我需要寻找一个新的网络主机。

问候,

院长。

4

3 回答 3

10

将以下内容添加到您的 .htaccess 文件中:

RewriteRule ^parked-directory - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com$ [NC]
RewriteRule ^(.*)$ parked-directory/$1 [L]
于 2011-11-13T19:42:24.470 回答
4

虽然不受欢迎,但可以使用 mod_rewrite 动态设置您的停放域子主机。

这是一个 .htaccess 示例,用于通过 mod_rewrite 使用动态格式进行多主机托管,该格式需要 parked-domain-name = sub-folder-name,并涵盖您网站上被重定向或忽略的其他托管域。

# tell mod_rewrite to activate and give base for relative paths
  RewriteEngine on
  RewriteBase   /

# permanent redirect of unused parked domains so they do not try to resolve.
# only use this redirect if you want multiple names to point to another.
# otherwise, replace the rewrite rule with: RewriteRule . - [F,L]
  RewriteCond %{HTTP_HOST}   ^(www\.)?parked-domain1\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST}   ^(www\.)?parked-domain2\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST}   ^(www\.)?parked-domain3\.com$ [NC,OR]
  RewriteCond %{HTTP_HOST}   ^(www\.)?parked-domain4\.com$ [NC]
  RewriteRule ^(.*)$         http://main-site.com/$1 [L,R=301]

# if you have an active site in hosting root folder,
# then tell it not to look for a subfolder by skipping next rule
  RewriteCond %{HTTP_HOST}   ^(www\.)?main-site\.com [NC]
  RewriteRule ^(.*)$         - [S=1]

# the domain-name = sub-folder automation
# thus parked-domain5.com in /parked-domain5/
  RewriteCond %{HTTP_HOST}   ([^.]+)\.com
  RewriteCond %{REQUEST_URI} !^/%1
  RewriteRule ^(.*)$         %1/$1 [L]

# if you're hosting wordpress sites, this is a tweaked variant of the WP code.
# add the rest of this example only if:
#   1. main-site.com is a WP site
#   2. you remove .htaccess in subfolders
# if (1.) true, yet keeping subfolder .htaccess, uncomment next 2 lines:
# RewriteCond %{HTTP_HOST} !^(www\.)?main-site\.com [NC]
# RewriteRule ^(.*)$ - [S=1]
#### BEGIN WordPress, improved
# if this request is for "/" or has already been rewritten to WP 
  RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file 
  RewriteCond $1 \.(gif|jpg|jpeg|png|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file 
  RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory 
  RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP 
  RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP 
  RewriteRule . /index.php [L]
# END WordPress
于 2013-04-07T12:47:22.940 回答
2

而不是使用“停放的域”,而是使用插件域 - 这里只是指向 public_html/sub-directory 的根目录,您要在其中指向新的“停放”域...

于 2011-11-24T16:49:18.373 回答