about a year ago, I moved a whole website to a new server. I still have access to the old server (which has a lot of junk on it) and I would like to have the old site redirect to the new one (they have different domains). The old server is running Apache. I thought something like this could be done via the .htaccess file so I put the following as my .htaccess file:
Redirect 301 / http://newsite.com/
This did not work and, upon accessing the old site, I got a "500 Internal Server Error".
I would rather delete the files from the old server. The problem is, though, that I am afraid that (since they are ranked pretty high on Google) if someone clicks on a link to one of those files, he will just get a "404 File Not Found Error". I just want to edit the .htaccess so that every file path on it will redirect to the new site. If you know how to do that, please help me. Thank you!
You should consider using mod_rewrite instead, assuming it is enabled on the old server:
RewriteRule ^(.*)$ http://newsite.com/$1 [R=301, L]
This preserves and appends the path to the new host
Related
I am having trouble with some old 301 redirects.
They have been removed from the htaccess but still seem to be working.
Some of the redirects have been removed for over 1 year but they still redirect as if they are present.
Ive tried different browsers/private browsing, restarting apache, flusing caches on the cms system and no luck.
The 301s were set out like this
Redirect 301 /example.com http://www.example.com/new-url
Our CMS is magento
Check if you have same redirects in Magento catalog rewrites (just a guess). Post your complete htaccess and give a real example of redirect. It can also be caused by custom varnish vcl (but very rare)
I fixed my issue by looking for other htaccess files in the ftp and found that an old htaccess had made its way into the root of the ftp which was conflicting with the correct one.
This was acting as a back up htaccess to the correct one and redirecting old URLS still.
For some time I used a free account to host my online forum. Recently I bought a domain name, and now it contains a full copy of all the php and mysql data in the forum, so now there are two copies of the forum in different locations. The last step I need to accomplish is to erase all the data in the old location, and replace it with a short htaccess file that will make a global redirect. What would the contents of this htaccess file look like ? I don't know enough Apache to be sure.
I found many related topics to this one here on MSE and elsewhere, but none that could match my needs exactly . Most are about redirections to just a subfolder inside a single server.
Note : the whole point of this question is that I wish the users of the forum to use the same URL as before, I wish to avoid to have to tell everyone that the forum's URL has changed. Nonprofessional users dislike changes
If mod_alias is active:
Redirect 301 / http://your-new-site.com
otherwise, if mod_rewrite is active:
RewriteEngine On
RewriteRule ^ http://your-new-site.com%{REQUEST_URI} [R=301,L]
Context:
I've recently moved a site to a new host, and moved the SSL certificate from the old host to the new one. The code, written in PHP, is a big mess made by someone no longer available many years ago. Because of this, I'm hoping to figure out something related to the configuration of the server that can fix the issue so I don't have to reverse-engineer the rather messy code.
Problem:
When users navigate to an area of the site that uses https://, all goes according to plan. The problem, however, arises when they click a link in the navigation that is normally to an http:// part of the site. On hover, you can see that the target URL incorrectly includes "https://". When the user tries to go to a non-secure area with https:// in front, either by clicking one of those altered links or by typing it into the location bar of the browser, they are redirected to the directory without any domain. For example, if you try to go to "https://domain.org/site/", the browser is redirected to only "/site", which of course cannot be found.
Theoretical solutions:
Is there a setting in Plesk which governs the "stickiness" of https? One way to fix the problem is to stop the non-secure links from acquiring https://.
Is there an obvious reason why whatever script or file the site is using to redirect would break when an un-secure area is accessed via https://? Is there a server setting that would have made this function differently on the new server via the old server?
I don't have access to see what exactly the configuration of the old server was. Is it likely that this could be caused by a difference in PHP version? If so, any suspicions about what the problem would be?
Is there some workaround with .htaccess that can manually redirect all but certain secure areas of the site to http:// when they are accessed via https://, presumably before the site's redirect script is activated?
Thank you for any help!!
Yes, since Plesk 17 (Onyx):
For older versions you can create .htaccess files which will rewrite request from https pages to http, based on referrer:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https://domain.org [NC]
RewriteRule ^(.*)$ http://domain.org/$1 [L,R=301]
I was doing some tests with mod_rewrite in my wamp environment.
I tested a simple rule that I put at the root of one of my websites and asked it to redirect any request ending with index.php to localhost (there is no sense to it, just wanted to check the rule)
It worked, but after, any change I'd made to my .htaccess file rule was not reflected.
After a while I just decided to delete the .htaccess... well it's still doing redirection! I just don't understand it. Does Apache cache the rules or something (restarting services trough wamp menu didn't change anything)
(Don't ask for the exact rule I used, since I deleted the file, I don't think it's relevant anyway)
.htaccess files are processed each time a request comes through. It is possible that your browser cached the request being forwarded. Did you try it with httpfox or anything to see what the headers said?
Have you tried deleting the browser cache?
So I'm trying to clean up the URLs on my site, and have digged around for information here and not figured out why I'm still getting errors.
Basically, I have a site that revolves around a search engine, and once the user sees the results and clicks on one, it goes to a URL that looks like:
www.mysearch.com/searchresults/204982398sjfdkf&thisismorejunk=junkjunk=1331
Well, sort of, but you get the point.
I want to clean this up for each result, so it looks like
www.mysearch.com/searchresult1001
I'm using the Joomla platform on my backend, and enabled 'Search Friendly URLs' and there was no problem (although it did almost nothing for me). Then before I enabled 'Use APACHE mod rewrite' I put the following code into my .htaccess file
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^Joomla161_2/joomla\.html http://www.joomla.org/? [R=301,L]
(The last rule was just to see if the rewrite rule works, which it does)
First problem - My host automatically overrides the Options command, saying I can't do it for security reasons - but I figure maybe this isn't big because the rewrite rule still works.
But then when I try to enable 'Use Apache rewrite' my whole site breaks. Worse yet, I have no idea what to do next to actually CHANGE the URLs of my search results.
Options +FollowSymLinks
It is very possible that your host has this enabled by default and
adding to your .htaccess file is causing a conflict.
If your mod-rewrites are working without it then there is no reason
to add it.
Joomla Apache Rewrite
Change the seo settings and htaccess back to default setting.
BEFORE! you change any of the options in the Joomla admin for seo friendly url's or Apache rewrite you must FIRST! rename your htaccess.txt to .htaccess
In some cases you may have to give the server a min or two to notice it.
Now change the Joomla admin settings to seo friendly and enable rewrite.
Search Rewrite
If the above setting are configured correctly then your websites search results will have landing pages with nice urls.