-2

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

5
  • 2
  • not work i want it dynamically
    – Alireza
    Jan 31, 2013 at 17:48
  • Quote: Then any request beginning with URL-path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-path will be appended to the target URL.
    – Quentin
    Jan 31, 2013 at 17:53
  • @Quentin i want it like fb.com to facebook.com when you write fb.com it goes to facebook.com and if you write fb.com/username it will redirect facebook.com/username
    – Alireza
    Jan 31, 2013 at 17:58
  • Yes. That is what the bold text means!
    – Quentin
    Jan 31, 2013 at 18:00

2 Answers 2

1

All you need is a Redirect directive:

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

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>
1
  • 1
    mod_rewrite is massively over complicated for this. You need a one line Redirect directive.
    – Quentin
    Jan 31, 2013 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.