Redirecting (301) from a shared htaccess - .htaccess

I need to redirect individual pages (each page to its new equivalent) from a domain www.mysite.de
to a subdomain de.mysite.com. The htaccess file of the original site is shared with other domains (other languages).
In order to complicate more, I have to redirect also certain folders that can contain hundreds of pages each, to a single page in the new subdomain (for each one of the original folders). For example everything under www.mysite.de/folder1/ to de.mysite.com/page1/.
Any ideas that would also be practical for a large set of redirects?
Thanks.

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.

I want that all my webpages have the same domain without the subdomain www

I have the same exact one page, which you can reach with this link
an with that one.
1. As you can see, the second link has the subdomain www. in it but I want that every one of my webpages have a domain without www.
I tried several redirects in the .htaccess file and i put this file in my domain root folder but none of them worked for me.
I have 13 webpages, which you can reach with and without www. and how can I just have the versions without www.?
The curious thing is that my starting page automatically redirects to the version without www. even if I type in the domain with www. It would be great if all my sites were reachable like my starting page.
2. Is this duplicate content and if yes, is it bad for the ranking of my website?

Redirects required for pages no longer in sitemap

I have a relatively new site that has just started to pick up a bit of traction in the SERP's. My problem is that I have published it and had it indexed with PHP URL extensions, as follows:
www.example.com/page.php
www.example.com/product.php
And so on. Obviously it is a fairly easy matter of editing the .htacess file to remove these extensions. So I will end up with:
www.example.com/page
www.example.com/product
No problems there.
Because the site is still quite small, I can easily change all the links manually to drop the .php extension, and then update the sitemap. So Google, and all users, should have no way of reaching the .php pages, although of course they still exist if you were to manually type them in.
But, because Google has a 'record' of these pages existing (even though there are no direct links to reach them now), do I need to implement 301 redirects from the .php pages to the new non-php pages? I.e. will Google try to crawl those pages that are no longer in the sitemap, but once existed? In other words, since you can still reach www.example.com/page.php , even though will be no link on the site or in the sitemaps that will take you there, would I get penalised for having duplicate content - are 301 redirects basically required when doing this kind of thing, even if there are no links to the content anymore?
Thanks very much.
It is better to have 301 redirect for some time(month or two) even though you can change all your links to nonphp urls. This way any residual URLs(will always be there) that are hanging out there will be taken care and google will index nonphp urls from your 301 redirect. Once you are sure from Logs(depending on your system) that there are no more OLD urls coming in, you can remove the 301 redirects. This is little easier way of moving all your old URLs instead of abruptly throwing 404s. 301 helps to transfer SEO values of old URLs to new ones.
Another item to look out for is using rel="canonical" if you want your .php and nonphp pages to coexist. This signals that they are not duplicates.

.htaccess 301 redirect for thousands of entries or RewriteMap

I have a site with thousands of pages that need to be redirected. I was thinking of using a 301 redirect in my .htaccess, but I'm just afraid that this will be very inefficient.
Would having a .htaccess with thousands of lines (there is no way to have a re-write rule, they have to be mapped one by one), mean that every time someone accesses one of our pages, they have to read the entire .htaccess? Is that a bad thing? This sit is in a shared host.
I saw a previous answer here about using RewriteMap. How is that different than having the 301 redirects?
Thanks
For simple page redirects 301 is the best and it's very fast. RewriteMap is for more complex rewrite functions or doing very specific rewrite tasks.
Before black listing your pages server side, I would try remapping with your application first.
If you set up the redirect with .htaccess those pages will be dead to Google which of course may or may not be a bad thing. Basically once Google indexes those redirects there really is no going back (SEO).
In short redirect wisely.

Redirect multiple files to multiple subfolders using rewrite and redirect

.htaccess redirect multiple files to same number in subfolder.
I need to accomplish the following:
receive these request at the main domain (root directory)
domain.com/customer-1.html
domain.com/customer-2.html
domain.com/customer-n.html
direct them to
domain.com/customer-1/
domain.com/customer-2/
domain.com/customer-n/
and in sub-directories:
/customer-1/
/customer-2/
/customer-n/
I need each sub-directory to rewrite the url to main domain
domain.com/customer-n/ ==>http://domain.com
the idea is to serve multiple customer essentially accessing same type of application on their own subdirectory but to the public to show that they are not sharing that domain.
and the subdirectories are all instances of the same joomla install with different templates.
thanks
first of all: it is not a good practice to share a database across multiple customers.
if you mean to share the same codebase, it is ok.
i dont know much about joomla, but must cms support multiple sites.
which mean they can serve independent domains, with the same codebase but different databases.
this may help:
Multi Sites
MS Control
another thing is to put your customers on a subdomain:
customer1.example.com
customerN.example.com

Resources