So I have a website with about 50 subdomains created. I want them all pointed to an external URL.
Ideally, I'd like ANYTHING written before the domain name to be redirected.
Meaning: xxxa.domain.com gets redirected. Same with 12213123123.domain.com.
To an external URL.
How do I do this using .htaccess? I've tried numerous code examples, but none of them work.
Related
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.
I have a domain which all the urls are structured like this:
http://www.documents-myapp.com/how-to-use
http://www.documents-myapp.com/basic-instructions
http://www.documents-myapp.com/configuration-setuo
http://www.documents-myapp.com/and many other urls
I want to setup a redirect so every individual page goes to a different domain:
https://myurl-myapp.com/documents/how-to-use
https://myurl-myapp.com/documents/basic-instructions
https://myurl-myapp.com/documents/configuration-setuo
https://myurl-myapp.com/documents/and many other urls
so the domain http://www.documents-myapp.com/ is changed to https://myurl-myapp.com/documents/ and the urls after remain the same.
Any ideas how to setup this redirect using wildcard?
I’m having some real problems with 301 redirects in my .htaccess file.
I have about 20 pages on an old site that I need to redirect to pages on a new site. The URL structure of the new site is totally different.
Here’s one that I tried:
Redirect 301 /dan-carr-gear-list/travel-gear https://dancarrphotography.com/gear/travel/
Unfortunately, this doesn’t work.
What happens is that you get redirected to https://dancarrphotography.com/gear/travel-gear/ for some reason.
I just can’t figure it out.
I have a domain e.g. named www.example.com, when people type in example.com, it still can be accessed, but won't automatically add that 'www' to the url.
But as for website like facebook, if you type in facebook.com, it'll automatically add that 'www', BEFORE loading the page for you.
Probably I didn't explain it well, but guess you see the difference and get my point anyway.
So how can I make my domain acts like facebook, when people type example.com, it'll automatically add that www for them?
EDIT:
Ok, so I need a redirect to the 'www' subdomain. Actually I'm using nodejs, which hosted on Amazon EC2, to serve the webpage instead of Apache HTTP. So any equivalent of .htaccess in nodejs area?
I guess now the question shifts to more nodejs oriented, and it turns out it becomes a redundant of this thread:
Redirect all requests using Express 3?
Thanks all for your help.
you have to set your domain 301 permanent redirect in your control panel.
if your website is hosted in CPANEL then
GOTO -> Redirects in ( Domains Menu )
Choose the type Permanent (301)
choose your domain.com
www.domain.com in redirects to→ __
check the box on Redirect with or without www
finally CLick ADD
if your website is hosted in PLESK then
do it in your program level
or
plesk11.0.29 version above supports the 301 peramanent
You can do all of this with a .htaccess file.
https://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/
Add this in a file named .htaccess on your host, but set it to the URL you want your main page to be.
To make a .htaccess file, you can always go in FTP, upload an empty .txt file, open it with notepad, put in the lines of code above, then rename it to .htaccess.
I would like a website to initially display intro.html when coming from external websites like google, or just from typing in the url. This intro.html and all internal links will link to index.php (wordpress blog so index.php can't change filename) which will then serve as the homepage. Can i do this with .htaccess, perhaps some rewritecond only on external links?
Yes, just redirect every request that does not come from your website, you can check this with HTTP_REFERER. This article should get you on the right path.