我已经在服务器中配置了我的项目
示例http://www.example.com
其中有一页http://www.example.com/products/index
现在我有其他新域http://dev.ny-sample.com
需要指向
我将新域指向http://www.example.com/products/index
但现在我需要在我的HTACESS文件中写一条规则http://www.example.com/
- 如果用户键入这些urlhttp://dev.ny-sample.com那么它应该重定向到http://dev-nysample.com/products/index
将此代码放入DOCUMENT_ROOT/.htaccess
文件:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www'.)?nysample'.com$ [NC]
RewriteRule ^/?$ http://%{HTTP_HOST}/products/index [R=301,L]
试试看,它对我来说很好。
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://www.example.com/product/index [R=301,L]
<IfModule mod_rewrite.c>
上的重写引擎
重定向/http://dev-nysample.com/products/index
<IfModule>
最终我在我的index.php 中做到了这一点
if($_SERVER['HTTP_HOST']='dev.ny-sample.com'&&($_SERVER['REQUEST_URI']=="/"){页眉('位置:http://dev.ny-sample.com/products/index/');}
我尝试了所有的访问方式,但它对我不起作用,可能是我不知道正确的方式。