How can I setup a redirect using an .htaccess that would keep part of the URL path?

How can I setup a redirect using an .htaccess that would keep part of the URL path? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the How can I setup a redirect using an .htaccess that would keep part of the URL path? error on your web browser. Problem :


I would like to setup a redirect using an .htaccess file which keeps part of the URL's path in the target URL. For example:



I have the domain example.com. I want example.com/social to redirect to twitter.com. BUT if someone types in example.com/social/Bob I want it to redirect to twitter.com/Bob, and would like it to work the same way for any value entered after the /social/ directory.



What might I add to an .htaccess file in order to do this?


Solution :

This should do it.



RewriteEngine On
RewriteRule ^social(.*) https://twitter.com$1 [R=301,L]

We hope that this article has helped you resolve the htaccess, redirects, url error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=