Mobile app version of vmapp.org
Login or Join
Smith883

: How can I setup a redirect using an .htaccess that would keep part of the URL path? I would like to setup a redirect using an .htaccess file which keeps part of the URL's path in the target

@Smith883

Posted in: #Htaccess #Path #Redirects #Url

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Smith883

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

This should do it.

RewriteEngine On
RewriteRule ^social(.*) twitter.com [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme