Redirect in subfolder based on url - .htaccess

I plan to run multiple sites on that server.
I looked arround a bit but only found rather cryptic stuff i can't work with.
So basically all projects reside in their subfolder in /var/www/. Multiple sites go with multiple domains, so what I want to accomplish is this:
http://example.com goes to my xx.xx.xx (serverip) and loads the site in /var/www/example/publicdir/index.php
http://something.else maps to /var/www/something/publicdir/index.php
Is it something that needs to be done in the apache on the server via virtualhosts? I'm completely clueless
Oh yeah I have an extra condition, I dont want 301 Redirects
I hope you can get through my babbling, my head feels like jelly since I'm trying to get it done for a few hours

Look into VirtualHost config. You don't need any mod_rewrite stuff. You can setup multiple domains in same Apache config with one VirtualHost section for each domain.

Basically what you want is to have different Document root for different domains. The example here will help you http://httpd.apache.org/docs/2.2/vhosts/mass.html#xtra-conf

Related

How can I display a subpage of my Silverstripe website as a subdomain?

I have a website build on Silverstripe 3.
Now I want that a user can enter the Subdomain URL info.mydomain.com and see the content of the page mydomain.com/subpage-url/. But without redirection. The subdomain URL should stay in their browser.
I already created the subdomain and let it point to the root directory of my website. As I understand it right I now need some rewrite conditions in my .htaccess file? And that is the point I struggle with. I googled a little bit and did some trail and fail but nothing seems to work. Maybe I understand it totally wrong, used the wrong rewrite conditions or insert them on the wrong place.. Maybe there are Silverstripe specific issues to pay attention to?
Long story short: I need help please!
As Robbie Averill pointed out in his comment, you could install the Subsites module. But you'd have to create a Subsite (eg. a separate site-tree) for every domain.
There's another module though, the homepagefordomain module. With that module you can specify one (or multiple) domains per page. When you visit one of these domains, the page that was specified as home-page for that domain will show up. I think this is a more flexible approach than messing with the .htaccess file.

Config mod_pagespeed for multiple domains

Is there a way to set multiple domains VirtualHosts with Google Pagespeed module?
I've tried this with ModPagespeedDomain with one domain of mine but not sure how to go about multiple ones I have about 14 on one server
I've also tried ModPagespeedMapOriginDomain but this doesn't seem to help either. I basically want combine_javascript and combine_css to work with all sites. I already have filters set up in the config file
ModPagespeed docs have a few examples for how to configure both server-wide and per VHost rewriters: https://developers.google.com/speed/pagespeed/module/configuration#virtual-hosts
You should be able to use ModPagespeedDomain to tell mod_pagespeed which domains to rewrite. Are basic rewrites like CSS minification and image re-compression working for you?
In order to get combine_* to work across multiple domains, you'll probably have to use ModPagespeedMapRewriteDomain to move them into one domain. Something like:
ModPagespeedMapRewriteDomain one.domain.com/shard1/ shard1.domain.com
ModPagespeedMapRewriteDomain one.domain.com/shard2/ shard2.domain.com
ModPagespeedMapRewriteDomain one.domain.com/shard3/ shard3.domain.com
ModPagespeedMapRewriteDomain one.domain.com/shard4/ shard4.domain.com
...
Then all rewritten resources from shard*.domain.com will be rewritten into one.domain.com.
Please read the documentation carefully, there are some assumptions that need to be satisfied for this directive.

.htaccess: Point Secondary Domain to Primary's Subdirectory

I have two domains on a VPS server, the primary "domain1.net" and the secondary "domain2.com". The website I have currently set up for domain2.com resides at domain1.net/subd1/subd2. I'm trying to create a rewrite rule for my .htaccess file so that whenever someone visits the site "domain2.com", "domain2.com/index.php", it grabs the page from "domain1.net/subd1/subd2", "domain1.net/subd1/subd2/index.php". I would like to do this while keeping "domain2.com" intact in the web address, instead of moreover redirecting it, and have all images/links appear from domain2.com.
From my understanding, it seems .htaccess's rewrite rule would be able to do such a thing, I just haven't figured out how the syntax would work. However, if there's a superior alternate method, I wouldn't be opposed to hearing it.
I appreciate anyone's help on this issue.

How to add something to start of url using htaccess?

I have seen sites that when you login it will look something like...
.example.localhost/blahblah.php
how is this possible with htaccess?
Any ideas
Do the files have to be placed in a seperate folder??
It's called sub-domain.
It has more to do with the DNS but htaccess can be used to modified its behavior.
Ie, point different sub-domain to the same folder.

Htaccess.. changing the domain name

I have a big Joomla website that was moved from .com to .eu domain.
The sites are on one web server.
On the old website there are a lot of links that point directly to oldwebsite.com/somethinghere.
Is there a way with Htaccess file in the old domains folder to redirect
from oldwebsite.com/somethinhere to newwebsite.eu/somethinghere?
Or maybe a way to do this on the new website folder?
Thank you,
Chris.
There are many ways, some people recommend using RewriteEngine, but there is an easier way:
Redirect 301 / http://domain.eu/
This will automatically handle files in the domain -- for example, old.com/foo will be redirected to new.eu/foo
EDIT: Regarding "301", that is the code for a permanent redirect. There also exist temporary redirects (I believe the code is 302), but it sounds like what you need is exactly this - a permanent redirect.
EDIT2: Oh and, I think the / after domain.eu may be required, but I'm not 100% sure - doesn't hurt for it to be there, that's for sure! I know that because I use the same kind of a redirect on a production website.

Resources