htaccess redirect from development server - .htaccess

The server where I developed a wordpress site was indexed by google. The site is now live with the actual domain, but google searches find links to the site at development server adddress. The site is on the same server where developed, making it live was simply pointing the domain to this new site. I need to redirect these links, but am not having an luck.
Also, the developer server address has a tilda, which was indexed as %7E in google. I have tried various version of the following, all to no avail.
RewriteCond %{HTTP_HOST} ^cardgym\.dcaccess\.net
RewriteRule ^cardgym.dcaccess.net/~chrs/$ http://chrs.org/$1 [R=301,nc]
RewriteRule ^/%7Echrs/(.*)$ http://chrs.org/$1 [R=301,nc]
going to development server results in an 404 error in wordpress: http://cardgym.dcaccess.net/~chrs/
Thanks

Can you change your internal web server configuration so that the development domain is an alias of the live site? That would be the easiest solution imo.
Otherwise check out the answer by Sigg3.net here RewriteRule for tilde

If I understand you correctly your site is live and you moved it to the new domain.
So it appears you already have the live site up and going at http://chrs.org. So there is nothing you need to do to redirect it as far as Google indexing.
It will take Google time to crawl the new site and index it.
You can help speed up the process by asking Google to index your new site by submitting it here.
https://www.google.com/webmasters/tools/submit-url?pli=1
.htaccess does not control the way Google indexes the site. If its on the internet it will be indexed unless you prevent it. There are a few options you can do to help make those dev links disappear.
A. Add a robots.txt to the root of the dev site with this code below in it and that will keep Google/search engines that respect robots.txt from indexing it.
# Make changes for all web spiders
User-agent: *
Disallow: /
B. Block the site using htaccess protected directory for the whole site which will stop it from being crawled.
OR
C. Take the dev site down.
It appears you've already moved the dev site to live domain that's why you are getting 404. The links in Google will disappear eventually because they no longer exist. The next time Google tries to crawl your dev site and see's it's not there the links will be removed. The new site will start to show up as Google begins crawling it. There is nothing you can do right now but wait. It can literally take weeks.
If indeed you really are trying to redirect, then you can add an htaccess file on the cardgym.dcaccess.net site using redirect.
Redirect 301 /~chrs http://chrs.org

Related

redirect numerous dynamic urls to home page via .htaccess

I am trying to clean up a previously hacked WordPress site, and domain name reputation, the site has new hosting and is now on a different CMS system, but there are hundreds of spam links in Google I need to get rid of, they look like example.com/votes.php?10054nzwzm75042pw205039
Domain name, then votes.php?**** etc.. Numbers letters all sorts.
So how do I redirect ANYTHING that starts with the domain name then /votes.php?***
Any help greatly appreciated
Unless you have multiple domains, you don't need to explicitly check the domain name.
To send a "410 Gone" for anything that contains /votes.php in the URL-path (and any query string), you can do something like the following at the top of your root .htaccess file using mod_rewrite:
RewriteEngine On
# Serve a 410 Gone for any requests to "/votes.php"
RewriteRule ^votes\.php$ - [G]
A 410 is preferable to a "redirect" if you want to get these URLs removed from the search engines as quickly as possible.
To expedite the process of URL removal from Google then use Google's Removal Tool as well.
If you redirect these pages to the homepage then it will likely be seen as a soft-404 by Google and these URLs are likely to remain in the search results for a lot longer.

my site hijacked, added url on my site and can't be redirected

My site hacked and they add url with string "bitsofev" for example:
http://example.com/~bitsofev
http://example.com/~bitsofev/apple.de
Check here for real sample
https://www.google.com/search?safe=off&q=bitsofev&nfpr=1&sa=X&ved=0CBsQvgUoAWoVChMI7LnMiOvIxwIVQpGOCh1T2wC6&biw=1570&bih=899
I tried to redirect it to homepage with htaccess but not working
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)~bitsofev(.*)$ http://example.com [L,R=301]
</IfModule>
I tried the same code to redirect other string and it works fine, but not "bitsofev" string. weird.
Best I can do for this is to block on robot.txt but its not solving the problem. What can I do for this?? Where can I fix the original problem? How to redirect it to homepage if I can't find the source?
Additional info: I searched on MySQL db, and I can't find 'bitsofev'.
I have a similar problem. Someone may have added the "/~bitsofev/apple.de" url to my site. A web analytics app track visitors and the content viewed at my site. Like you I don't have many users. Originally I thought that the "/~bitsofev/apple.de" was first accessed sometime last month. I originally also noticed that one of the user at my site registered at nearly the same time. My first thought was to temporarily deny this user access to signing into the site (and interacting with mysql db) while I investigated if this user uploaded a malicious file to the mysql db or exploited some error in the code that I was not aware of. However, I subsequently discovered (I hadn't been monitoring it regularly) a message from google regarding the url "~bitsofev/apple.de" in my admin inbox which predates the web analytics data and the user's registration that I originally thought may have been suspicious.
I will let you know everything further that I ascertain.
I meant to post this as a comment and not an answer. I apologize.
Add the the following to your .htaccess file:
RewriteCond %{THE_REQUEST} ~bitsofev/apple.de($|\ |\?) [NC]
RewriteRule .* - [F]
This will block (403 error) the file and url from being accessed. However, it wont specifically correct the problem.
I believe that was is really happening is that you are using shared hosting at Hostgator and IP 108.167.182.250 / 108.167.182.251
bitsofev (the owner of the site http://bitsofeverything.net/) is another user on the Hostgator shared hosting.
For example, go their website and after .net/ type in the tilde "~" symbol and the your user name (your hostgator user name), e.g, ~username
If I'm correct you'll then see your own website. You can then add a / and folders/files and see those, as well.
This is because Hostgator enables (by default) mod_userdir (Apache server).
The only part I don't understand yet is the apple.de because it doesn't appear to be a folder or file at bitsofeverything.net/
At any rate, I've been writing about this for a couple of months (trying to understand it better) at:
Justinbailey.info: What is /~bitsofev/apple.de added url? Hacked, hacker hacking.

new to .htaccess, how to redirect specific page to mainpage

I'm new to .htaccess file.
My site is hosted on 1and1 and by default it shows www.mydomain.com/defaultsite when nothing is uploaded to my account. Now I've uploaded my wp site and have managed to make it go to index, but if someone inputs in the url www.domain.com/defaultsite he will still get the wrong place.
How can I manage this issue with .htaccess file so that any request to defaultsite will take the user to www.mydomain.com ?
I'm not a 1and1 user, but this could be a DNS cache issue. First, check your document root for the presence of a directory called defaultsite. If it exists, remove it. If not, then you can attempt removing it using mod_rewrite. Insert this rule immediately after RewriteEngine On in your .htaccess file:
RewriteRule ^defaultsite/?$ http://yourdomain.com/ [R=302,L]
If it's working for you, you can safely change 302 to 301 to make in permanent and cache-able.
I have also seen comments referring to an index.html file in the document root. If you see one, delete it - it could be that, internally, 1and1 maps defaultsite to index.html.
Also, it will help for you to clear the cache in your browser when testing. If using Chrome, you can open the Developer Tools (Ctrl+Shift+I), click on the settings cog at the top right of the panel that opens, and check 'Disable cache (while DevTools is open)`.
I had a similar issue and was pulling out my hair trying to figure this out. 1&1 is hosting while Namecheap holds my domain. I was able to access my page without /defaultsite on Safari and mobile Chrome. But on desktop Chrome I was being redirected to /defaultsite.
To remedy this I cleared my cache, flushed my DNS cache, and cleared my browsing history. Not sure if the latter 2 were necessary but having done all three it did help resolve this issue.

How to STOP redirecting my website to mobile.mywebsite.com in smartphones

I have developed a website www.mywebsite.com and it is ready to go live.
I have used Codeigniter framework.
When I enter www.mywebsite.com from any android/iphone, it redirects automatically to mobile.mywebsite.com and displays page not found error. I dont have any mobile site developed for this. I want to show the main site even on the smartphones.
I am not good at .htaccess file, and I am using default .htaccess to remove the index.php in the url.
I tried creating a subdomain mobile.mywebsite.com and pointed to root path. But same response. I search online, but didnt find anything on how to STOP redirecting.
Thanks in advance.
When I was uploading my local files into the server I was NOT overwriting the old ones assuming the folder is clean and no need to overwrite. But my hosting provider has default .htaccess which is redirecting to the mobile site.
I deleted the old one and gave my .htaccess without the mobile redirection and everything is in place now

.htaccess rewrite base url for Wordpress

Ok sorry if this has been asked before but I could not find a working solution. I am using wordpress multisite. This is what I am trying to achieve.
Currently the domain http://mynew.com/ redirects (via my hosting co.) to one of the sites on my wordpress multisite installation as follows http://myold.com/subsite/
But I want to hide/swap the urls as follows, http://myold.com/subsite becomes http://mynew.com and all links that follow (eg. http://myold.com/subsite/another-link becomes http://mynew.com/another-link) without breaking.
I tried this in my .htaccess file which rewrote the url successfully however the links did not work and returned 404 errors.
RewriteRule ^subsite/(.+) http://mynew.com/$1 [R,L]
Hope that makes sense, thanks for your help.
Of course it will get you a 404 error, you redirected the request from the old site to the new site, but the new site does not contain the requested pages, so it through you a 404, what you need to do is to redirect from the new site back to the old site INTERNALY (that means without changing the browser address bar), but this requires your new site to work as a proxy server, see http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

Resources