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
Advertisement
Answer
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.