Fernanditos
asked on
Help 301 Redirection rule
Hi,
The normal URL structure on my site is:
site.com/search/pdf/harry+ potter
by accident I got lot of URLs indexed in Google this way:
site.com/search/harry+pott er
site.com/search/book+title
etc...
The wrong URLs are leading to a page with error.
I need to write some 301 redirection rule on my .htaccess to redirect ALL links like
site.com/search/book+title
to
site.com/search/pdf/book+t itle
The attached code is the content of my .htaccess inside /search/ folder.
Please help, help!
Thank you in advance.
The normal URL structure on my site is:
site.com/search/pdf/harry+
by accident I got lot of URLs indexed in Google this way:
site.com/search/harry+pott
site.com/search/book+title
etc...
The wrong URLs are leading to a page with error.
I need to write some 301 redirection rule on my .htaccess to redirect ALL links like
site.com/search/book+title
to
site.com/search/pdf/book+t
The attached code is the content of my .htaccess inside /search/ folder.
Please help, help!
Thank you in advance.
RewriteEngine On
RewriteBase /search/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.) /search/index.php?query=$1 [L]
i want to say you answer but you made some mistakes.
SEO tip: instead or + using - it's better.
for redirecting site.com/search/some+thing to site.com/search/pdf/some+t hing add following code to .htaccess
SEO tip: instead or + using - it's better.
for redirecting site.com/search/some+thing
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]
# REDIRECT ALL /SEARCH/* TO /SEARCH/PDF/*
RewriteCond %{REQUEST_URI} /search/.*
RewriteRule search/(.*) search/pdf/$1 [R=301,L]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
# Redirect old file path to new file path
Open in new window