从URL中删除文件夹名称

I have a domain www.domain.com redirected to / in my server.

Next I have index.php whith code:

header("Location: http://domain.com/v3/");

When I enter mydomain.com I have mydomain.com/v3/ in url.

How to remove v3 from Url

Remove header line from your PHP code since it is doing a redirect and have this lookahead based rule in your root .htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+v3/([^?\s]*) [NC]
RewriteRule ^ /%1 [R=302,L,NE]

RewriteRule ^((?!v3/).*)$ /v3/$1 [L,NC]

Which basically means if request is not starting with /v3/ forward to /v3/ without changing the URL in browser.

If you're redirecting from PHP, you can use parse_url to clean it up.

$url = "http://domain.com/v3/";

$host = parse_url( $url, PHP_URL_HOST); 
$scheme = parse_url( $url, PHP_URL_SCHEME); 

header( $scheme . '://' . $host );