Htaccess subdomain exceptions to rewriterule - apache

I host in siteground, on a multiple domain account,
Main domain is pointed to public_html, so it's a bit dangerous for the rest of sites in the account to use it (unwanted deletes, hacks, and so...)
I successfully followed this guide (http://www.ianholden.com/how-to/hide-joomla-subdirectory/) to point mydomain.com to midomain.com/mydomain folder (joomla install)
But now I have a problem with existing subdomains for sites still without their own domain names, that give a 500 error when visited...
What could I use to leep my current rewrite rule mydomain.com -> mydomain.com/mydomain and make exceptions for subdomains as whatever.mydomain.com?
Thanks

The problem is that the rule that you have added to your .htaccess file will affect all other sites on your hosting account, since the .htaccess file is at the same level of all those sub-directories.
If you have too many sites hosted this way, then I suggest you go with a VPS, and then create an account for each and every domain that you have. This will ensure that your websites run smoothly and in silos.
Whatever you do to make Joomla work properly under a subdomain, will create problems for you on the long run.

Related

HTTP access was forced to visit HTTPS

I have a few web sites that are hosted in a VPS.
Today, I found that when visiting "http://api.rsywx.com", it forces me to visit "https://api.rsywx.com", and the redirects me to "https://rsywx.net" (which is SSL enabled).
I checked my virtual host files, and did not find out anything forcing this redirect.
Anyone can point me some direction on how this can happen?
Redirects can be done on different ways and levels. Most elegant ways in descending order (my opinion):
Apache conf (mostly in /etc/apache2/apache2.conf)
.htaccess - file
in the index.php or the used backend script/code
(- could be even done in the frontend with javascript files but for that the page must be loaded and then will be redirected.. So nothing somebody should use)
Problem solved. I added one line in my Silex application's entry index.php to require HTTPS access, which is meant to be locally tested only.

How to point different domains to the same site

I've found myself in a situation where I have to use different domains for the same site.
It's a multilingual website that uses the path for the language so I have something like:
mysite.com/en
mysite.com/es
mysite.com/fr
mysite.com/ru
What I need is something like
mysite.com/en
misitio.es/es
monsite.fr/fr
bladimir.ru/ru
It's an Apache server. We enabled domain aliases and if I enter misitio.es the server redirects the web browser to mysite.com/es but showing misitio.es in the url.
What I would need is each domain to work on their own, not redirecting me, sharing all the content and source code. There should be no differences neither in files or in the database, and the htaccess should be configured to redirect each language (/es, /en, /fr, /ru) to its respective domain (*It's the last thing to do, we have not changed thw htaccess file yet).
I've found this guide for multisites in drupal, but it explains how to build a multisite from zero and my website is already in production, also, I'm not sure on how does it apply to my specific problem.
Is it possible to achieve what I need?
Any advice would be helpful.

.htaccess IP redirect based on country without installing module

Found several threads on here about this but they require a module being installed, or require a index.php file.
The requirement is to redirect a visitor to a particular sub-directory on my site if they are from a specific country (in this case, anyone from Czech Republic need redirecting to www.mysite.com/cz)
I'm on a shared (apache) server, and the host of that server doesn't allow modules to be installed, such as this one: https://www.ip2location.com/developers/apache
I ideally want to insert a simple line of redirect to the .htaccess.
My homepage is taken from index.html, if it makes a difference in the answer
Advice on the best solution to make this work please

Way to get around subdomain vs subfolder in terms of SEO?

I have a main domain, www.example.com, that has ranking and 'trust' in Google. I'm creating a blog, but, for various reasons, I HAVE to host it on a subdomain, sub.example.com.
I know that when a subdomain is created, Google treats it as a new site and will eventually see it as part of the main domain (after a very long while). What I'm looking for here is a way around this or a way to expedite this process. Is it possible?
Possible solutions:
Using modrewrite to rewrite sub.example.com to www.example.com/sub. I'm not too familiar with rewriting so I'm not sure if it works like this. If it does, would this be a solution to this issue?
Creating a subfolder on www.example.com like www.example.com/sub, and, in that subfolder, include a redirect to sub.example.com. That way when Google crawls www.example.com/sub it will find the link to sub.example.com. Will it then see the subdomain as part of the real domain?
Are these viable solutions? Is there anything else that could be done?
Thanks.
mod_rewrite won't let you convert the subdomain to a folder, but mod_proxy will.
You'll want something like this in your apache config file in the virtual host section for www.example.com:
ProxyRequests Off
ProxyPass /sub http://sub.example.com/
ProxyPassReverse /sub http://sub.example.com/
Then your blog is running in both places. You'd probably want to put canonical tags on it so that Googlebot knows which is the preferred one.
Google treats subdomains and subdirectories the same. They do not see subdomains as new websites.

How to keep URL unchanged after redirecting from one subdomain to another subdomain

I want to redirect all the queries from mobile.mydomain.net to web.mydomain.net, keeping the URL mobile.mydomain.net displayed in the address bar.
The directory structure in my service provider is the following:
/root
-/vrmd
--/homepages
---/myusername
----/mydomain
-----/subdomains
------/web
-------/public
------/mobile
In my service provider configuration the address www.mydomain.net points to /mydomain/, the address web.mydomain.net points to /mydomain/subdomains/web/public/ and the address mobile.mydomain.net points to /mydomain/subdomains/mobile/.
If I echo the value of the $_SERVER['DOCUMENT_ROOT'] constant in a simple PHP script (/mobile/index.php), it outputs /homepages/myusername/mydomain/subdomains/mobile.
I have some questions:
1) Where should I put the rewrite conditions and rules? In an .htaccess file under /mydomain or better under /mydomain/subdomains/mobile...?
2) Which conditions and rules should I write? For example, I want mobile.mydomain.net/blog to show only the contents of web.mydomain.net/blogs, but not the address.
Can anyone help me?
You can't silently redirect domains like that with the Apache rewrite engine - which is probably a good thing, since this could end up as a pretty nasty security breach if someone was able to upload a malicious .htaccess to your site somehow.
You would be better off implementing a front-facing controller in your mobile site that then included the content and libraries from your main website.