301 redirect not working (server fault) - redirect

I'm a beguinner and I don't know much about web programming and different ways to do redirect.
I'm trying to do a 301 redirect from an old site to a new site, for seo purpose. My problem is that the old site is not hosted on regular hosting, but on http://pages.videotron.com/duclosma/controlemd.html .
Therefor, regular 301 redirect with the .htaccess doesn't seem to work.
Do you guys have any solution on how to do a proper redirect?
Thanks

You could do a Javascript redirect.
At the top of the page(s) You want to redirect.
window.location = "http://yournewsite.com";

Show the htaccess file your attempting to use what are the conditions you are trying?
Also as an alternative though won't give you the code for 301/302 is the good ol fashion meta based refresh assuming you have access to the html file above.
<meta http-equiv="refresh" content="3; url=http://mynewsite.com/">
Also theres other concepts if you have access to the files on the server where the original page was hosted. You could if you have access to the files, is delete them from the server drop a htaccess that acts as a catch-all redirects everything to a php file, where the php file redirects with headers in it similar to how Wordpress handles its htaccess. All in all though it depends on what rights you have over the location of that hosted old site. As you need to make sure any htaccess, or anything else you put is on the same server that its on to redirect to the new server.
EDIT
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourolddomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yournewdomain.com/$1 [R=301,L]

Related

Redirect 301 after domain change

I had to do a domain change on a website so I moved from www.mydomain.it to www.mydomain.eu. At the moment I don't have full control on the .it domain so when it was the time to make the domain change I asked the hosting provider to make a 301 redirect of the .it to the .eu so as a result, I got all the pages of the .it website redirected to my .eu's homepage (no 404 errors) because the previous website used queries as pages' URLs.
This is a link example of the previous website:
http://www.mydomain.it/index.php?page=lkr_pg_chisiamo
So what I started getting after the redirect was:
https://www.mydomain.eu/index.php?page=lkr_pg_chisiamo
which gave me back the homepage content as a result and not a 404 error.
The old website had at least 10k links like that one so each of them started having the behavior of the link above, I got the homepage content for all links. In the beginning, I thought it was a good thing for me because I wasn't getting 404 errors but then I started digging around on the web and I found out to not be a good practice because all links might be recognized as soft 404 errors.
Obviously before I made the domain change I had created all the 301 redirects of the most important pages of the website like this:
RewriteCond %{QUERY_STRING} ^page=lkr_pg_chisiamo$
RewriteRule ^(.*)$ https://www.mydomain.eu/chi-siamo/? [R=301,L]
RewriteCond %{QUERY_STRING} ^page=lkr_pg_contattaci&form_key=25-8124355$
RewriteRule ^(.*)$ https://www.mydomain.eu/contatti/? [R=301,L]
And so on..
Obviously, I didn't do that for all the 10k pages, but just the most important, so the other links are still pointing to the homepage content.
After I did this, I told Google I had changed the domain through the Google Search Console.
After a few weeks, I started seeing some results on Google but after one month I'm not still happy with them, I think I lost rank on Google. I know it could take a while more to do everything and that I should probably lose 3% of my "domain juice" after a domain change but what I was wondering if I have done everything in the right way in order to not lose rank.
My concern now is about all the links that I wasn't able to redirect and that has been redirected automatically and started getting the homepage content. Should I be worried about them?
How should I manage them?
Should I redirect them to another page which is not the homepage?
If yes, is there a way to redirect all those links (just those) even though I have all the other redirects in my .htaccess file?
Was there a better way to redirect all the 10k links of that type? How would I be able to do that?
You asked this 6 months ago, but i hope i can help you.
Add this to your .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.it$ [NC]
RewriteRule ^(.*)$ http://mydomain.eu [R=301,L]
This should redirect all links to your new domain.
About Google Search Console, take a look here: https://support.google.com/webmasters/answer/93633?hl=en
About changing domain, look at: https://support.google.com/webmasters/answer/6033049?hl=en
Hope this helps!
Brhaka

Redirect URL permanentally to page not found

I have the following issue related to URL rewriting. I am sure there must be some good solution to this.
I converted this URL
domainname.com/index.php?page=product&pid=5&proTitle=Samsung Galaxy
After rewrite it looks like this
domainname.com/products/5/Samsung-Galaxy.html
The .htaccess code looks like this.
RewriteRule ^products/(.*)/(.*).html$ index.php?page=product&pid=$1&proTitle=$2 [nc]
Rewrite Works fine. However, if I try to access old URL i.e domainname.com/index.php?page=product&pid=5&proTitle=Samsung Galaxy the page is still accessible and on top of that being crawled by Google and other search engines. I want If someone tries to access this URL, it should direct them to Page Not Found and this should also not be sniffed by any crawlers.
I am sure there must be a smart way of doing this. Awaiting for some valuable suggestions.
in htaccess insert this code :
the code can make the URL "domainname.com/index.php?page=product&pid=5&proTitle=Samsung Galaxy" look 403 Forbidden
insert this for direct if browser find the url is 404 or 403 :
ErrorDocument 404 /errormessages/404.php
ErrorDocument 403 /errormessages/403.php
you can change the path /errormessage/404.php or 403.php like what you want
and insert this "don't use space" :
< IfModule mod_rewrite.c >
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.(\?page=product&pid=$1&proTitle=$2). [NC]
RewriteRule ^(.*)$ - [F,L]
< /IfModule >
I don't think you should really make the page inaccessible since people might have bookmarked it, and you're just making it harder to get back to where they were. If your main problem is Google still referencing it, then use rel="canonical" and specify the URL you'd rather have Google use. https://support.google.com/webmasters/answer/139394?hl=en

Show a wordpress page in Facebook Page as a Site, using app_data paremeter

Good fellas,
My client requested a site in Wordpress, for now I will call www.example.com, but he wanted the site displays it too as a Facebook Page. Because the server with SSL is for other domain www.serverssl.com, I put the wordpress site at a relative directory on serverssl, so I have this:
www.serverssl.com -> Document Root: /var/www/html/ (using ssl)
www.example.com -> Document Root: /var/www/html/example/site
For Facebook Page -> www.serverssl.com/example/site (using ssl)
Because Wordpress is configured at relative path, at first time when I tried to get at Facebook Page it didn't work. So I've added some lines to .htaccess at Document Root of Wordpress:
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://www.example.com/$1 [R,L]
So, if I tried to reach www.facebook/com/Client/app_00000000/ the iframe redirect to www.example.com so works fine.
Well, the client now wants other think: He wants a link to enter a Facebook Page that shows a specific page in wordpress. So I thought use app_data parameter, like this:
www.facebook.com/Client/app_00000000?app_data=specificpage
then at header.php of wordpress' theme evalutes the $_REQUEST['signed_request'] parameter in order to search the app_data and then redirect to specificpage.
But the header.php nevers see the REQUEST send by Facebook,
I tried with the .htaccess:
RewriteCond %{QUERY_STRING} ^signed_request=(.*)$ [NC]
RewriteRule . http://www.example.com/%{QUERY_STRING} [R,L]
Still does not sent the signed_request.
Any idea how reach send signed_request through redirect?
PD: Sorry my bad english :(
If you load the page in a Facebook iframe it will always pass the signed_request on the first load.
I am not too great with mod-rewrite but I would suggest verifying the rewritecond on the signed request. Other values may have being transferred as well causing your condition to fail.

htaccess rewrite one file type with get variables

i think header is confusing, here is the situation.
i host some video files and want to use on my website. but only on my website. if you realized facebook did this. but we dont have servers like them -nginx i guess-.
finally i want to redirect all requests to a certain page. like that
if someone request that
http://www.blabla.com/videos/1.mpg?hash=12345&expire=1234567
htaccess redirect that request to
http://www.blabla.com/check.php?file=videos/1.mpg&hash=12345&expire=1234567
but also if someone type
http://www.blabla.com/videos/1.mpg
it is also redirect to check.php
http://www.blabla.com/check.php?file=videos/1.mpg
RewriteCond %{QUERY_STRING} ^hash=(.*)$
RewriteRule ^(.*)/videos/(.*)$ /check.php?file=videos/$2 [R=302,L,QSA]
Now your rewriteRule will only be applied if query string contains hash=xxxxx
use R=301 if you want users to be redirected permanently

Sitewide 301 Redirect

I am looking to perform a sitewide 301 redirect. The original site is over 15 years old! I understand the concept of making the .htaccess file with the code:
redirect 301 "/old/old.htm" http://www.you.com/new.html
However will this redirect every page of the old site? or just an individual page. How do I achieve redirection with the entire site?
I have a rewrite in .htaccess (apache rewrite mod enabled), all pages from old site
http://www.old.com and
http://www.old.com/site/index.php? .... redirect to the new site
http://www.new.com or
http://www.new.com/website/index.php?... (notice that /site/ and /website/ are different names)
pages from the old site
https://www.old.com (notice the s on https://) get redirected fine but pages from
https://www.old.com/site/index.php?... do not, they get a 404 error
since the old site is not secure anymore neither the
https://www.old.com or
https://www.old.com/site/index.php?... really exist anymore but
https://www.old.com gets redirected and the ones with
/site/index.php?... added do not get redirected but go instead to a 404 error
Be careful with a 301, 301 redirect is used for where content has moved.
e.g. content about making a cake was here /makeacake.html now is /cakes/making-a-cake.html.
what I would recommend is find the pages where the majority of your uses come to, and redirect those pages to the new relevant pages / sections and just delete the rest and add a custom 404 error page. which tells them the old content has been moved.
You can also use goggle web masters to remove pages from there index.
Assuming the old pages don't exist any more (would throw 404-errors), you can do the following: You redirect all the pages that don't exist anymore to the start page. (As specified in the comments below.)
This is the updated .htaccess code you can use to make that happen. The first RewriteCond checks if the requested path is a file, the second checks if its a directory. After that, you get redirected to the startpage - or any other page for that matter.
http://www.example.com/i/am/an/old/page.html or http://www.example.com/i/am/a/different/old/page.html will all redirect to http://www.example.com/
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [R=301,L]
The best way to redirect the entire site is by doing domain forwarding through your web server (or web host... most have the option in their control panel).
Domain forwarding is much more efficient than sending 301 redirects back to the client.
Am I right in thinking that your site is on the same domain name but you've changed it structurally?
So, you have a load of old page URLs that have now changed to new URLs (but on the same domain).
For example, you may have had:
www.yourdomain.com/about-us/history.htm
that has now become
www.yourdomain.com/our-history.htm
If that is the case you will more than likely need to set up many 301 redirect rules. It doesn't necessarily mean that you have to set up one rule for every single page change as you can use RegEx to catch pattern changes in the URL structure. As a scale example, I recently set up a htaccess file of 301 redirects for a site with just under 600 changed URLs. There were 70-something 301 Redirect rules in the end.
It's not necessarily a small job but it is doable. Worth it to retain your SEO rankings.