【问题标题】:Real subdomains with GodaddyGodaddy 的真实子域
【发布时间】:2013-06-28 01:02:56
【问题描述】:

我的 .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^deathga.me$ [NC]
RewriteRule ^(.*)$ http://deathga.me/$1 [L,R=301]
</IfModule>

它正确地从 www.deathga.me 重定向到 deathga.me,这解决了很多问题。但它也会将 play.deathga.me 重定向到 deathga.me/play/ ,这是不可取的。

我的问题基本上与此相反:Redirecting http://example.com to http:/www.example.com while keeping http://subdomain.example.com access intact。只有我不知道如何将它应用到我的网站,即使是看着那个问题,谷歌搜索并尝试了很多事情。问题本身很简单:如何将 www.example.com 重定向到 example.com,但将 sub.example.com 保留在该子目录中?我什至不确定这是 Godaddy 还是与htaccess ...我应该从哪里开始研究?这是 Godaddy 子域配置截图:

编辑:现在完整的 .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} !^play.deathga.me$ [NC] 
RewriteCond %{HTTP_HOST} !^deathga.me$ [NC]
RewriteRule ^(.*)$ http://deathga.me/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>

【问题讨论】:

  • 用于调试 1) .htaccess 是否被网络服务器读取? (例如使语法错误) 2)子域使用这个.htaccess 吗? (例如做一个简单的重写规则:RewriteCond %{HTTP_HOST} ^play.deathga.me$ [NC] RewriteRule ^(.*)$ google.com [L]
  • 是的,它正在被读取,它有另一个条件,使deathga.me/whatever 在内部充当deathga.me/index.php?url=whatever,它可以正常工作。更新了完整的 .htaccess

标签: php .htaccess redirect lamp


【解决方案1】:
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteCond %{HTTP_HOST} !^play.deathga.me$ [NC] 
RewriteCond %{HTTP_HOST} !^deathga.me$ [NC] 
RewriteRule ^(.*)$ http://deathga.me/$1 [L,R=301] 
</IfModule>

【讨论】:

  • 那很好...我实际上想要没有www 的站点,问题是它还删除了play.deathga.me 中的play
  • 它仍然将 http://play.deathga.me/ 重定向到 http://deathga.me/play/ 与新的条件......这可能是一个 Godaddy 问题吗?
  • 好吧。它出什么问题了。您要求 1) 将每个 deathga.me 重定向到 deathga.me 但不是子域。或者play.deathga.me 应该被重定向到deathga.me/play
  • 不,它不应该被重定向。它正在被重定向(这就是我问这个问题的原因),即使有你的解决方案,我也无法阻止它重定向......
【解决方案2】:

显然,我想做的事不能用“假”godaddy 子域和经济帐户:Setting up a "real" subdomain with Go Daddy

感谢@borazslo 提供的所有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-01
    • 1970-01-01
    • 2017-07-05
    • 2017-07-13
    • 2017-06-25
    • 1970-01-01
    • 2021-01-29
    • 1970-01-01
    相关资源
    最近更新 更多