使用请求的URI重定向到不同的URL

使用请求的URI重定向到不同的URL

问题描述:

Hi i want to redirect every requested URI to another URL with the same URI :) Like this

http://www.fb.com/everything

redirects to

http://www.facebook.com/everything

and

http://www.fb.com/anotherthing

redirects to

http://www.facebook.com/anotherthing

I want it dynamically

either using php or htaccess

您好我想将每个请求的URI重定向到另一个具有相同URI的URL:) 这个 p>

  http://www.fb.com/everything
  code>  pre> 
 
 

重定向到 p>

  http://www.facebook.com/everything
 代码>  PRE> 
 
 

和 p>

  HTTP:/  /www.fb.com/anotherthing
nn

redirects to p>

  http://www.facebook.com 使用php或htaccess  p> 
  div

All you need is a Redirect directive:

Redirect 301 / http://www.facebook.com/

To redirect all traffic from that hits your htaccess use the following code

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]
</IfModule>