Redirect Sub Directory Google

I was working on my Dev site and closed the store as often as poss, I also had a disallow/dev set in robots.txt but I have come to search site:mysite/dev in google and see it has crawled a few thousand urls.

I am about to transfer the dev site to root and dont want google to see it as duplicate content. Can anyone tell me how to add something in .htaccess to 301 redirect all /dev urls to root please

Thanks

John

Please check the following example:

https://perishablepress.com/redirect-subdirectory-to-root-via-htaccess/

no sorry, still cant get it.They all just redirect to homepage instead of product url.

eg I have 2000 of these url in google

www DOT hivis.co.uk/v4/ppe-provided-sign-en.html

and just want the redirecting to

www DOT hivis.co.uk/ppe-provided-sign-en.html

I have used this example

RedirectMatch 301 ^/v4/.*$ http://hivis.co.uk/

my htaccess is below if anyone can help

DirectoryIndex index.html index.php

# Compress HTML, CSS, JavaScript, Text, XML, fonts
AddOutputFilterByType DEFLATE application/javascript application/x-javascript text/javascript application/json
AddOutputFilterByType DEFLATE application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf font/opentype font/otf font/ttf application/x-woff application/x-font-woff
AddOutputFilterByType DEFLATE text/css text/html text/plain

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent




Header set Access-Control-Allow-Origin "*"


Cache all images for 2 weeks

ExpiresActive on ExpiresDefault "access plus 2 weeks" Header set Cache-Control "max-age=1209600" RewriteEngine on # Please note that RewriteBase setting is obsolete use it only in case you experience some problems with SEO addon. # Some hostings require RewriteBase to be uncommented # Example: # Your store url is http://www.yourcompany.com/store/cart # So "RewriteBase" should be: # RewriteBase /store/cart RewriteBase / Options -MultiViews

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} ^api/(.)$ [or]
RewriteCond %{REQUEST_URI} .
/api/(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .api/(.)$ api.php?_d=$1 [L,QSA]

RewriteCond %{REQUEST_URI} .(png|gif|ico|swf|jpe?g|js|css|ttf|svg|eot|woff|yml|xml)$ [or]
RewriteCond %{REQUEST_URI} store_closed.html$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.?)/(.)$ $2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]

This prevents possible problems when downloading files

php_flag zlib.output_compression Off php_value max_execution_time 3600

Please try

RewriteCond %{HTTP_HOST} ^www.hivis.co.uk
RewriteRule ^dev/(.*)$ http://www.hivis.co.uk/$1 [L,R=301]

Thanks eComlabs, worked

John

You are welcome