Config mod_pagespeed for multiple domains - linux

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.

Related

Ignore last part of URL with .htaccess

We have a FAQ page /faq (tab style) where every question should have its own 'ghost' url/page. So users could visit eg.
/faq/question-1
/faq/question-2
/faq/question-3
The problem is question-1, question-2, question-3 are not actual pages but just sections on /faq. For SEO, aesthetics and usability reasons we do not want to work with ?q= or #
I've searched and tried every .htaccess thread I came across but without result.
Is there a way we can show the page/faq when visiting /faq/question-1 and keep the url /faq/question-1 with mod_rewrite? (we cannot hardcode it because we do not know all future question slugs) So basically something that tells the browser: if the first url part is /faq/, just ignore everything that comes behind but keep the url.
Thanks
This is a trivial rewriting task and it is unclear why this should not work for you:
RewriteEngine on
RewriteRule ^/?faq/.+ /faq [END]
Since you claim that you "tried every .htaccess thread you came across" and this clearly works the question is: why not in your setup? But since you did not tell us anything about your setup we cannot really offer more help...
These are some general hints though which you should go through:
Where did you implement the rules you tried? In the http server's host configuration or in a distributed configuration file?
If you are using a distributed configuration file (".htaccess") then how did you make sure such files are interpreted by your http server and how did you test that?
Did you check your http server's error log file for hints?
Did you make sure that you are not actually looking at cached responses? So did you really test with a fresh anonymous browser window using a "deep reload"?
Since the CMS you are using requires own rewriting rules, where did you add those rules you tried? Remember: the order is important!

Solve redundant hostnames in Play Framework

In my Play 2.4.x Web Application I am getting told by Google Analytics that I have two redundant hostnames namely
domain.net
www.domain.net
From an SEO standpoint it's important for me to fix this isse.
Normally this could be fixed with a .htaccess file doing a redirect from one of those two to the other one.
I want to know how I can achive the same solution using Play's application.conf file.
Reading the documentation I figured something like this could solve the issue:
%production%.application.baseUrl="http://domain.net/"
I am not sure though if this is enough.
What you want to do is create a filter that checks the incoming hostname, and if it's www.domain.net, redirect to domain.net. This would be equivalent to the Apache .htaccess. Of course, if you have a reverse proxy in front of Play (which you probably should, this is considered good practice) eg nginx or haproxy, then you can implement the redirect in there.

Redirect in subfolder based on url

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

Symfony2/ get variable from subdomaine and htaccess

I using Symfony2.
What would be the best practice to get a variable from URL. I am using subdomain to get the city.
Ex: paris.website.com
how do I get Paris as variable.
I believe I need to play with Kernel and htaccess, but I haven't figured out how.
Thanks if you can put me on right tracks about that.
Cheers,
Pierre.
You should read the documentation of Symfony. One of the basis components of Symfony is the Routing that provides exactly what you need :
www.mysite.com/paris/
Using the subdomain is not the solution, but you can play with .htaccess to rewrite subdomain paris.mysite.com to www.mysite.com/paris (if web server allows it) after having configured your route in Symfony.

URL /subdirectory match with port number

I would like to ask how to set in the webserver, APACHE.
eg. like cPanel webmail, user only need to enter
http://www.example.com/webmail then it will match with http://www.example.com:2095/
I not sure it is set with .htaccess or set it at router level.
Can anyone advice how to do this?
It's called Reverse Proxy (even if you use it on the same server) : http://en.wikipedia.org/wiki/Reverse_Proxy
It can be done on Apache using standard modules mod_proxy and mod_rewrite. I have not done it myself on Apache, so I cannot tell if mod_rewrite will actually be required here ... but a lot of examples I have seen utilizing functionality of both of them.
There really a lot of examples around -- you should have no issues finding them. Start at the following links:
mod_proxy Apache manual
Using mod_rewrite for Proxying

Resources