【发布时间】: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