I did some redirects 301 from my old domain to a new domain on new host. It works well, but I'm having a lot of 404's on google webmasters generated by dynamic search pages. E.g.: www.newdomain.com/store/catalogsearch/result/index/?cat=60&dir=desc&limit=15&mode=grid&order=price&p=2&q=makita. But, I think this was crawled in the old domain, because of the searched words and are redirecting now to the new domain. Is there some generic rule to redirect all the others dynamic generated searchs to a specific page like home page on new domain without drop my ranking on google? On my new domain, dynamic search pages have been blocked in robots.txt. Is this way enough to not be crawled again? This is part of my redirect:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index)\.(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ http://www.newdomain.com/$1 [R=301,NC]
RewriteRule ^store/?$ http://www.newdomain.com [L,NC,R=301]
RewriteRule ^store/folder/?$ http://www.newdomain.com.br/otherfolder/another-folder/ [L,NC,R=301]
RewriteRule ^store/folder1/folder2/?$ http://www.newdomain.com/folder-3/folder-4 [L,NC,R=301]
...
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,NE,L]
Thanks in advance for your help.
ok insert this rule just below RewriteEngine On to redirect these dynamic URLs to home page of new domain:
RewriteCond %{THE_REQUEST} /store/catalogsearch/result/index/ [NC]
RewriteRule ^ http://www.newdomain.com/? [L,R=301]
Related
I've merged two websites in to one. The domain that is no longer in use (oldwebsite.com) already has a 301 redirect to the new site (newwebsite.com)
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.oldwebsite\.com$
RewriteRule (.*) https://www.newwebsite.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^oldwebsite\.com$
RewriteRule (.*) https://www.newwebsite.com/$1 [R=301,L]
I'm setting up redirects in my .htaccess file for newwebsite.com to direct them to the new path correctly. The path structure is very much the same with the exception of languages as the root of the site cannot be translated, only pages within /contents/
I want it so if the user has visited www.oldwebsite.com/fr/contents/blogpost/first-post for example, they will be redirected to www.newwebsite.com/fr/contents/blogpost/first-post
Does this need to be done on the old website or the new website's htaccess file?
I seem to be getting a lot of Internal Server Errors and pages redirecting to a 404 instead of where it is supposed to.
For instance if I visit www.oldwebsite.com/de/ it will take me to a 404 instead of https://www.newwebsite.com/de/contents/
This is the htaccess file on the new website (newwebsite.com)
#FR
RewriteRule "^/fr/(.*)$" "https://wwww.newwebsite.com/fr/contents/$1" [R=301,NC,L]
#DE
RewriteRule "^/de/(.*)$" "https://wwww.newwebsite.com/de/contents/$1" [R=301,NC,L]
#ES
RewriteRule "^/es/(.*)$" "https://wwww.newwebsite.com/es/contents/$1" [R=301,NC,L]
#IT
RewriteRule "^/it/(.*)$" "https://wwww.newwebsite.com/it/contents/$1" [R=301,NC,L]
#PT
RewriteRule "^/pt/(.*)$" "https://wwww.newwebsite.com/pt/contents/$1" [R=301,NC,L]
#LV
RewriteRule "^/lv/(.*)$" "https://wwww.newwebsite.com/lv/contents/$1" [R=301,NC,L]
#SR
RewriteRule "^/sr/(.*)$" "https://wwww.newwebsite.com/sr/contents/$1" [R=301,NC,L]
#JA
RewriteRule "^/ja/(.*)$" "https://wwww.newwebsite.com/ja/contents/$1" [R=301,NC,L]
#ZH-TW
RewriteRule "^/zh-tw/(.*)$" "https://wwww.newwebsite.com/zh/contents/$1" [R=301,NC,L]
I'm breaking my head in redirecting a few page from my old asp website to my new php website.
For example, I want to redirect permanently the following 2 pages from my asp website to my php website
1) http://www.mywebsite.com/shopdisplayproducts.asp?id=11&cat=food&sortorder=mostrecent&page=1&pagesize=12
TO
http://www.mywebsite.com/index.php?route=product/category&path=10_11
where 11 should be the link between old and new website to display the correct page.
2) shopexd.asp?id=3903&prod=food&vrnt=green&mrk=studio&cat=11
TO
index.php?route=product/product&path=10_11&product_id=3903
where the number 11 is the link between old and new url for the category and the number 3903 is the link for the product number
I have the following rewrite rule in my htaccess page for the first redirect, but it seems not be triggered. What is wrong? Please help.
RewriteCond %{REQUEST_URI} ^/shopdisplayproducts\.asp\?id=([0-9]+).*$ [NC]
RewriteRule ^shopdisplayproducts\.asp\?id=([0-9]+).*$ index.php?route=product/category&path=10_$1 [R=301,L]
I also tried:
RewriteCond %{REQUEST_URI} ^shopdisplayproducts\.asp\?id=([0-9]+).*$ [NC]
RewriteRule ^shopdisplayproducts\.asp\?id=([0-9]+).*$ index.php?route=product/category&path=10_$1 [R=301,L]
Thanks for any help
Sabko
You need to use QUERY_STRING variable in rule condition:
RewriteEngine On
# /shopexd.asp?id=3903&prod=food&vrnt=green&mrk=studio&cat=11 to
# /index.php?route=product/product&path=10_11&product_id=3903
RewriteCond %{QUERY_STRING} ^id=(\d+)&.*&cat=(\d+) [NC]
RewriteRule ^shopexd\.asp$ /index.php?route=product/category&path=10_%2&product_id=%1 [R=301,NC,L]
RewriteCond %{QUERY_STRING} ^id=(\d+) [NC]
RewriteRule ^shopdisplayproducts\.asp$ /index.php?route=product/category&path=10_%1 [R=301,NC,L]
I have one project online and it on two diffrent domains 1)www.example.com and 2)www.example.co.in. now, I want to redirect
www.example.co.in/category/
to
www.example.com/ceramic+industry/
And I want to redirect it through .htaccess or from server. I tried from server that only redirect domain name not directory, and also tried from .htaccess where I can redirect only domain or only directory not when both domain and directory combine. My project in php. So, you can give advise if it's possible in php also.
Add following rule in .htaccess(placed at root of website www.example.co.in):
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^category/(.*)$ http://www.example.com/ceramic+industry/$1 [L,R=301]
or use 302 for temporary redirects.
IF you also want to redirect whole .co.in website to .com THEN add next line(remember in .com website's .htaccess these two Rules should not be there.)
RewriteRule ^category/(.*)$ http://www.example.com/ceramic+industry/$1 [L,R=301]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
If for any reason you are bound to use same .htaccess on both site then use condition like this:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^category/(.*)$ http://www.example.com/ceramic+industry/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
============================================================
Solution to your another query:
This can be done by PHP. As I guessed all URL after category/ is handled by one PHP page.
in that PHP page code this at top:
if(isset($_GET['company'])){
$company=$_GET['company'];
$companyNew=str_replace('_','+',$company);
if($company!=$companyNew){
header("location:/category/?company="+$companyNew,true,301);
//header("location:/ceramic+industry/?company="+$companyNew,true,301);
exit;
}
}
You can try this:
RewriteCond %{HTTP_HOST} ^your.first.domain$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ http://your.second.domain/$1 [R,L]
This will redirect, if your request contains existing directory name.
Answer to your comment. You can try this:
RewriteCond %{ENV:REDIRECT_FINISH} !^$
RewriteRule ^ - [L]
RewriteCond %{QUERY_STRING} ^company=(.*)\_(.*)$
RewriteRule ^(.*)$ /$1?company=%1+%2 [R,L,E=FINISH:1]
First two lines allow you to prevent infinite loop redirect.
I'm trying to redirect all my visitors from the old domain that I use to the new one.
Here is the content of the .htaccess file that I use
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !foobar.com$ [NC]
RewriteRule ^(.*)$ http://foobar.com/$1 [L,R=301]
where http://foobar.com is the new domain.
The code above works but only if the visitor type http://olddomain.com.
What I mean is when the visitor types
http://olddomain.com/terms.php he should be redirected to http://foobar.com/terms.php
I want that whatever the visitor types after the old domain name (like http://olddomain.com/privacy.php, http://olddomain.com/users.php, etc) they go to
http://foobar.com/ not to http://foobar.com/privacy.php etc.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^foobar\.com$ [NC]
RewriteRule .* http://foobar.com%{REQUEST_URI} [L,R=301]
I have a problem since i using rewrite url..
MY OLD URL:
Website.com/index.php?act=appdetail&appid=oWV
New Rewrite URL
http://website.com/angry_birds_rio-appdetail-oWVi.html
But all my old url are indexed in google and if any one come to my website its display the old URL and google also INDEXED the NEW URL. its make duplicate page on website problem.
Let me know the solution
My rewrite URL htaccess
RewriteEngine On
RewriteRule ^([^-])-([^-])-([^-])-([^-])-([^-]*).html$ index.php?appanme=$1&act=$2&appid=$3&page=$4&cat=$5 [L]
RewriteRule ^([^-])-([^-])-([^-])-([^-])-([^-])-([^-]).html$ index.php?appanme=$1&act=$2&appid=$3&page=$4&cat=$5&sString=$5 [L]
RewriteRule ^([^-])-([^-])-([^-]*).html$ index.php?appanme=$1&act=$2&appid=$3[L]
Here is your .htaccess file:
RewriteEngine on
RewriteRule ^/index.php?act=appdetail&appid=oWV$ http://website.com/angry_birds_rio-appdetail-oWVi.html [R=301,L]
You'll need to inform to web crawlers about the redirection, you cando it with a 301 code.
Appears the rule are .htaccess based; you need an additional set of rules to permanently redirect (301) BROWSER/CRAWLER requests for the index.php pages, if a set of CGI arguments are present, to the appropriate alias, this will tidy up Google in a few weeks. Then your rules above e.g.
RewriteEngine On
RewriteBase /
#Permanently redirect BROWSER requests for the index.php?xxx to the appropriate page alias:
RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteCond %{QUERY_STRING} ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)&page=([^&]+)&cat=([^&]+)&sString=([^&]+) [NC]
RewriteRule ^.* http://%{HTTP_HOST}/%1-%2-%3-%4-%5-%6.html [R=301,L]
RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteCond %{QUERY_STRING} ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)&page=([^&]+)&cat=([^&]+) [NC]
RewriteRule ^.* http://%{HTTP_HOST}/%1-%2-%3-%4-%5.html [R=301,L]
RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteCond %{QUERY_STRING} ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+) [NC]
RewriteRule ^.* http://%{HTTP_HOST}/%1-%2-%3.html [R=301,L]
# Followed by: YOUR RULES FROM ABOVE
Note:
1) There appears to be a typo in YOUR second rule: sString=$6 NOT sString=$5
2) The Apache mod_rewrite documentation is worth a read if your unclear as to what the above rules do, or if you want something a little more abstract consider the following post.