Apache vhost_alias - apache2

I have a question about vhost_alias
I got it working, it does the following job:
vhost.subdomain.domain.com -> sends to /var/www/vhost
using virtualdocumentroot and %1
But I don't like that I can access the same content also like this
vhost.vhost.subdomain.domain.com
since I have ServerAlias to *.subdomain.domain.com
How can I force that only vhost.subdomain.domain.com works?
The aim is to have many vhosts like this, for exmaple vhost1, vhost2, etc.
Thanks,
David

One solution you could try is to add a fixed subdomain in your ServerAlias, before your actual dynamic subdomain:
Example:
ServerAlias www.*.subdomain.domain.com
This will ensure that
vhost.vhost.subdomain.domain.com
does not redirect, however, you will be forced to always add www. before your name.

Related

How to return the same content for any path base on User Agent?

I run a server with the URL pattern http://*.self/. Based on the client's User Agent string i need to return the same content whatever their path may be. In example:
http://example.self/foo
http://example.self/bar
http://example.self/asdf
Will return this exact same content by /path/to/search-bot/index.php:
<body>
<h1>Thou sahll not!</h1>
</body>
Here is my apache VirtualHost:
<VirtualHost *:80>
ServerName self
ServerAlias *.self
VirtualDocumentRoot /some/path
</VitualHost>
The following...
BrowserMatch "(?i:Googlebot)" no_bot=1 #google
<If "reqenv('no_bot') == 1">
AliasMatch .* /path/to/search-bot/index.php
</If>
...gives me this error after running service apache2 restart:
AliasMatch not allowed here
EDIT
For the issue about Clocking for Google, yes, i understand, but i DO intend to get penalized by Google. I have special reason to.

Apache 2 /httpd vhost dynamic documentroot

I have an app in folder /var/www/test
Also there is an "sub-app" in folder /var/www/test/subapp (There is another index.php inside
If user will type test.com the index.php of test should trigger but when user type test.com/triggersubapp the index,php from /var/www/test/subapp shall run.
I failed to create correct statements and RewriteRules and I haven't got much time left. So have any one of You know how to do this easiest way or maybe have a correct definition?
I would greatly appreciate it !!!
EDIT
The main index.php and .htaccess are in /var/www/test/public/. :(
Put this in your .htaccess in root directory:
RewriteEngine On
RewriteRule ^triggersubapp/?$ subapp/index.php
This will rewrite triggersubapp to subapp/index.php which means if user enters test.com/triggersubapp he/she will see result for test.com/subapp/index.php

Access to shared_path in deploy.rb

I try to set command map using shared_path like that:
SSHKit.config.command_map[:composer] = "php #{shared_path.join('composer.phar')}"
But the path is /var/www/xxx not using the path I set on :deploy_to deploy/staging.rb.
I guess this is because staging.rb is loaded after.
What the right way then?
I had the same issue and although I don't think I have found the best way. I have found a way.
My default :deploy_to in deploy.rb points to '/var/www/my_app'. And I have a development stage where the server uses the same path. But my production server uses '/home/httpd/something/else' so I put :deploy_to in production.rb expecting it to deploy to that path. And everything works except the composer command. The composer.phar file is downloaded to the correct shared path and the files are deployed correctly. But when composer runs it tries to find it in '/var/www/my_app/shared'.
What I did was instead of putting the SSHKit.config.command_map by it self in deploy.rb, put it in a task. Something like:
namespace :deploy do
before :starting, :map_composer_command do
on roles(:app) do |server|
SSHKit.config.command_map[:composer] = "#{shared_path.join("composer.phar")}"
end
end
...
end
It feels like SSHKit.config.command_map runs "to early" or something. This seems to help. It works for me at least. And I had the exact same issue.
Edit:
I got some help from an issue I posted on capistrano/composer.

CakePHP 2.1 new install Missing Controller Error

I am completely new to CakePHP and installed 2.1. I am getting this error:
Missing Controller
Error: Index.phpController could not be found.
Error: Create the class Index.phpController below in file: app\Controller\Index.phpController.php
<?php
class Index.phpController extends AppController {
}
Notice: If you want to customize this error message, create app\View\Errors\missing_controller.ctp
Stack Trace
APP\webroot\index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
ROOT\index.php line 40 → require(string)
I followed their guide at http://book.cakephp.org/2.0/en/installation/advanced-installation.html and tried everything it stated:
I enabled mod_rewrites (they were already enabled from something else)
I have all the .htaccess files in the directories
I have cake installed under my document root so I access it at localhost/cakephp/index.php
I do not know where to proceed from here. Thanks for any help you can give me.
Update: I just re-read your question and realized you're loading http://localhost/cakephp/index.php. Don't do that. Since you appended "index.php", it is trying to load a controller called "index.php" and the action "index" for that controller. Resulting mapped path to the "index.php controller" is app\Controller\Index.phpController.php.
Since you have the rewrites enabled, browse to http://localhost/cakephp without appending any filename.
Original answer:
Assuming you're using Apache, double-check the .htaccess in your /app/webroot directory. It should include the following:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Based on your error, it doesn't look like it's properly appending the path after your index.php file.
If you are using cakephp 2.0 or greater than rename the controller file name as the class name.
ie TaskController.php
class TasksController extends AppController {
--Your code inside class
}
I hope this will help you
the easiest solution is to stick to the "live environment" as close as possible.
this means using vhosts to use a "domain" and correctly root down to your webroot dir:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
this leaves almost no room for error and also helps with other potential problems like "absolutely linked asset files" etc

Bugzilla change the url in link in email

How can i change the value of "urlbase" param globally in bugzilla ?
If you are an administrator, it's under Administration > Parameters.
Had the same problem recently installing bugzilla3 on Ubuntu 10.04LTS
Rather than edit the /usr/share/perl5/Bugzilla/Constants.pm file, I saw that if the variable debian_webpath is set to the value of the environment variable X_BUGZILLA_WEBPATH.
If not set, then it defaults to /bugzilla3/ .
Make sure that mod_env is enabled in your apache setup (a2enmod env).
Then in my apache configuration file (/etc/apache/hosts-available/default), I added lines
<VirtualHost *:80>
...
SetEnv X_BUGZILLA_WEBPATH /bugzilla/
...
</VirtualHost>
Also logged in to bugzilla and set the urlbase in the section: Administration > Parameters.
urlbase = http://my-server-name/bugzilla/
It didn't work well in Ubuntu 9.04, it still doesn't in Ubuntu 10.10.
Change the following line in /usr/share/perl5/Bugzilla/Constants.pm
$overwritten_locations{'debian_webpath'} = '/your_url_prefix_here/';
/etc/apache2/conf.d/bugzilla3.conf
Alias /your_url_prefix_here /usr/share/bugzilla3/web
sudo vi /etc/bugzilla3/params
'urlbase' => 'http://your_domain.tld/your_url_prefix/'
maybe also you'll need to adjust /usr/share/bugzilla3/debian/params
(same as item #3 above)
Good luck! ;)

Resources