httpd subdomain 404 error

I have a working site at on the Top level of a domain, I now want to add a subdomain on the same domain and the same server.

The files for this site are located in the public html folder (/var/www/html)

I have the following virtualhosts/directory config in httpd.conf

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/joomla3
    ErrorLog logs/support.somesite.com_error.log
    CustomLog logs/ common

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/moodle
    ErrorLog logs/moodle.error.log
    CustomLog logs/moodle.access.log common

<Directory "/var/www/html/moodle">
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride None
Options None
Order allow,deny
Allow from all

No errors are reported on the start/restart of httpd

Nothing is reported in the httpd error log. The below entry is shown in the Access log so the request is reaching the webserver but appears to be not being handled properly by the webserver. - - [05/Jan/2015:12:49:14 +0000] "GET /moodle HTTP/1.1" 404 290

I have configured something similar before but I can't figure out the problem here. I might have missed something obvious, Can you see where the problem is, Thanks?

I am running CentOS 6.5 for reference.

Malformed Apache requests

I am facing an issue where the Apache requests are malformed and is causing unusual behavior with the application. We have Webcache servers in front of Apache webservers. The requests in the Webcache servers are fine but they end malformed at Apache webservers.

Request in Webcache access log: Request is well formed with GET or POST (xx.xx.xx.xx - - [Timestamp] "GET /abc/def.htm HTTP/1.1" 501 559 "referrer URL" "browser/5.0 (Linux; U; Android 4.2.2; locale; SM-G386F Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 " "" 0.009315)

Corresponding request at Apache webserver is malformed as yy.yy.yy.yy xx.xx.xx.xx - - [timestamp] "GET /abc/def.htm HTTP/1.1" 501 990 "referrer URL" "-"

Some characters are getting added before the actual request ("GET /abc/def.htm HTTP/1.1") and such requests are not getting blocked/ handled at Apache but are making it to the Application servers that are behind the webserver.

Apache version: Apache/2.2.27 OS: SunOS

Please let me know if anyone has faced such an issue and how can this be handled.


Linux Performance issue High disk IO r/w [on hold]

Need your help n determining my server issue. My site is intermittently slow.

Following is the iostat output.

Linux 2.6.32-504.3.3.el6.x86_64      01/05/2015      _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           8.77    0.09    1.27    0.05    0.00   89.81

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             141.03      1011.83      3668.84  124475718  451342400

Is this load normal for a 12GB RAM instance with 16 processor cores?.


How to redirect to a URL with a query string?

I've seen questions regarding redirecting a URL with a query string to a new URL that doesn't contain a query string.

Unfortunately I have to do this in reverse, my knowledge of redirecting in Apache isn't good, and I can't find any information about doing this.

So for example I need to redirect something like:




The new URL structure is obviously not ideal, but this is something that is out of my control.

I've tried:

RedirectMatch 301 /news/news-item

But obviously this doesn't work.

From what I understand I need to use RewriteRule, can somebody point me in the right direction?

A big issue with re-direction via .htaccess in some complex case

I have a web directory site that was previously in the root folder, but because of having to re-develop the site, I moved this to a folder, a few days ago so it is at Google on the hand, the primary provider of guests still has thousands of links it assumes are still located in root folder & so I have been getting hundreds of page not found errors.

At the time I moved this directory, I placed a Wordpress-based site in the root folder & submitted site maps for both to Google, though I guess it will take a while before the urls are in the Google db.

For the old site, I still need it for a couple of months and moved it to, ... all links are still valid only that, they have the directory "oldsite" appended to So for a link in the Google database like, this becomes The regional directory covers about 20 different countries.

Links like "" or like will indeed never exist again & until the old site is discontinued, will have that directory added as explained above. I wonder how to best deal with that.

Is it for example possible or does it make sense to say use some code in .htaccess for all links directed to, or, or ... by Google to be redirected to their new locations,, ... .... without creating any error messages?

If so, what exactly would this .htaccess code look like? (Not a coder ;) ). If that is possible, I can add this code, if I had it.

I must add that, the directories like countryA, countryB, etc do not exist in root folder & are created dynamically. This is because I saw in some tutorial I think that a directory named in some .htaccess code for re-direction must exist & have content, or something like that.

Since the new site in root folder is Wordpress-based, I thought I could use one of the many re-direction page not found plugins, but most of these mostly deal wit simple re-direction or work for WP sites, but the directory in this case is not WP-based.

The link structure generally for directory links only changes with the new folder being placed after ".com" so we have something like ".com/countryname/..." changing to ".com/oldsite/countryname/...", otherwise everything is the same. There are otherwise thousands of listings in total, but each listing basically begins with a country directory, etc so we have something like => now =>, etc

The writer of the directory script says something like they can "add many redirection rules to the .htaccess file of your WordPress. We will need to add these rules in the way they will not effect WordPress links. " ... but the hefty price frightened me & made me come to request for help here, which I would appreciate.

I would do this myself if I could code ... ,)

I can also clarify specific issues if asked.

Any assistance would be very much appreciated.

Kind regards & thank you in advance

How do I use JCIFS with apache VFS to access an SMB URL – part 2?

I had the same problem: How do I use JCIFS with apache VFS to access an SMB URL?

... after including commons-vfs-sandbox-2.1-SNAPSHOT.jar in the classpath I now get this exception:

Exception in thread "main" org.apache.commons.vfs2.FileSystemException: Could not determine the type of file "smb://".
    at org.apache.commons.vfs2.provider.AbstractFileObject.attach(
    at org.apache.commons.vfs2.provider.AbstractFileObject.getType(
    at org.apache.commons.vfs2.provider.AbstractFileObject.exists(
    at VFSTest.main(
Caused by: jcifs.smb.SmbAuthException: Logon failure: account currently disabled.
    at jcifs.smb.SmbTransport.checkStatus(
    at jcifs.smb.SmbTransport.send(
    at jcifs.smb.SmbSession.sessionSetup(
    at jcifs.smb.SmbSession.send(
    at jcifs.smb.SmbTree.treeConnect(
    at jcifs.smb.SmbFile.doConnect(
    at jcifs.smb.SmbFile.connect(
    at jcifs.smb.SmbFile.connect0(
    at jcifs.smb.SmbFile.queryPath(
    at jcifs.smb.SmbFile.exists(
    at jcifs.smb.SmbFile.isDirectory(
    at org.apache.commons.vfs2.provider.smb.SmbFileObject.createSmbFile(
    at org.apache.commons.vfs2.provider.smb.SmbFileObject.doAttach(
    at org.apache.commons.vfs2.provider.AbstractFileObject.attach(
    ... 3 more

Please advice.

PHP unable to create directories or files on AWS EC2 instance running RHEL v7.0

After having installed Apache and PHP on a fresh EC2 instance running Red Hat Enterprise Linux and after going over all the instructions about setting file permissions in Amazon's tutorial on installing a LAMP stack, running scripts that contains calls to functions such as mkdir or file_put_contents from a browser continue to fail due to inadequate file permissions, as per the received errors:

Message:  file_put_contents(./dist/js/1be6169d48b8d39917769068f05f9972.js): failed to open stream: Permission denied

In addition to the tutorial from Amazon, after noticing that the set group | user pair within the httpd.conf file is Apache | Apache, I've also added the user Apache to the www group, but to no success.

What is the deal with the file permissions errors?

Apache PHP with XCache, do I need to optimize Apache modules?

In Centos 6.5 machine, 3 CPU total 9 GHz, 8 GB RAM, Plesk 12. PHP 5.4.36, Apache/2.2.15, Apache run PHP as PHP module, XCache 3.2.0.

Currently I see 180-200 simultaneous visitors in popular hours. 40-50 simultaneous visitors average.
Current httpd.conf values:

Timeout 60
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000

xcache.ini values:

xcache.size  24M
xcache.count 1
xcache.slots    8K
xcache.var_size 1M
xcache.var_count    1

xcache screenshot 1
xcache screenshot 2

I'm checking what can I do more to optimize Apache. I checked top state, it's like this:
Top results image
Note that each Apache process takes 55-100 mb, where shared memory for each httpd process is 18m.

I'm curious that whether disabling some Apache modules is good or bad.
Because of XCache is it meaningful to disable unused modules ?
Or is it not logical to disable them because in peak times system creates 30-32 httpd processes and it doesn't take too much ?
Currently active apache modules are like this: screenshot

httpd process' memory, cpu and count graph

I restarted httpd process and I see following values: top image
Note that average httpd process decreased 67 mb to 34 mb.

skip subdirectory when replacing underscore to hyphen from urls using .htaccess code

I have to replace _ (underscore) with -(hyphen) from urls for the SEO purpose.I have hundreds of files so I can't change filenames one by one.So I wrote some .htaccess code to do that.

This is the code I am using.

RewriteRule ^([^_]*)_(.*)$ /$1-$2 [R=301,L] 

It successfully changing my urls from underscore to hyphen.

Now I have one subdirectory named "administrator" and I dont want this directory urls to replace from underscore to hyphen.

So I want to skip urls of this directory to skip from .htaccess code.

Please help me how to skip this.


Running multi tenancy on same port with apache web server – NameBasedVirtualHsoting

I have been working to get multi tenancy running on same port on same ip address. I have achieved the objective with different ports but I can't run the same on one port only. Here the apache web server redirects the request to weblogic host on same machine. I have gone through multiple guides but it is not working as expected. I have configured two virtual hosts for same port with URL as localhost:9010/site1 and localhost:9010/site2. The configuration in httpd.conf is mentioned below. I don't know where I have made the mistake so I have kept whole configuration file.

    Define SRVROOT "D:\Apache24"
    ServerRoot "${SRVROOT}"

    Listen 9010
    #Listen 9011

    LoadModule actions_module modules/
    LoadModule alias_module modules/
    LoadModule allowmethods_module modules/
    LoadModule asis_module modules/
    LoadModule auth_basic_module modules/

    LoadModule authn_core_module modules/
    LoadModule authn_file_module modules/
    LoadModule authz_core_module modules/
    LoadModule authz_groupfile_module modules/
    LoadModule authz_host_module modules/
    LoadModule authz_user_module modules/
    LoadModule autoindex_module modules/
    LoadModule cgi_module modules/
    LoadModule dir_module modules/
    LoadModule env_module modules/
    LoadModule headers_module modules/
    LoadModule include_module modules/
    LoadModule isapi_module modules/
    LoadModule log_config_module modules/
    LoadModule mime_module modules/
    LoadModule negotiation_module modules/
    LoadModule proxy_module modules/
    LoadModule proxy_ajp_module modules/
    LoadModule proxy_html_module modules/
    LoadModule proxy_http_module modules/
    LoadModule setenvif_module modules/
    LoadModule socache_shmcb_module modules/
    LoadModule ssl_module modules/
    LoadModule xml2enc_module modules/

    <IfModule unixd_module>
    User daemon
    Group daemon

    <Directory />
            AllowOverride ALL
            Require all granted

    DocumentRoot "${SRVROOT}/htdocs"
    <Directory "${SRVROOT}/htdocs">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted

    <IfModule dir_module>
            DirectoryIndex /home

    <Files ".ht*">
            Require all denied

    ErrorLog "logs/error.log"
    LogLevel warn

    <IfModule log_config_module>
            LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
            LogFormat "%h %l %u %t \"%r\" %>s %b" common

            <IfModule logio_module>
                LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

            CustomLog "logs/access.log" common


    <IfModule alias_module>
            ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"

    <IfModule cgid_module>

    <Directory "${SRVROOT}/cgi-bin">
            AllowOverride None
            Options None
            Require all granted

    <IfModule mime_module>
            TypesConfig conf/mime.types
            AddType application/x-compress .Z
            AddType application/x-gzip .gz .tgz
            AddType text/css .css
            AddType text/javascript .js

    <IfModule proxy_html_module>
    Include conf/extra/httpd-proxy-html.conf

    <IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin

    ProxyRequests on

    ProxyIOBufferSize 65536

    SSLProxyEngine on

    ErrorDocument 403 /home
    ErrorDocument 404 /home

    NameVirtualHost *:9010

    <VirtualHost *:9010>
        ServerName localhost:9010/site2
        LogLevel info

        <Location />
            SetHandler weblogic-handler

        ProxyPass /site2 http://localhost:7001
        ProxyPassReverse /site2 http://localhost:7001
        ProxyPass /Login.zul http://localhost:7001/Login.zul
        ProxyPassReverse /Login.zul http://localhost:7001/Login.zul

        <IfModule mod_weblogic.c>
            WebLogichost localhost
            WebLogicPort 7001
            debug OFF
            FileCaching OFF
            MatchExpression *
            KeepAliveSecs 540

    <VirtualHost localhost:9010>
        ServerName localhost:9010/site1
        LogLevel info

        <Location />
            SetHandler weblogic-handler

        ProxyPass /site1 http://localhost:7001
        ProxyPassReverse /site1 http://localhost:7001
        ProxyPass /Login.zul http://localhost:7001/Login.zul
        ProxyPassReverse /Login.zul http://localhost:7001/Login.zul
        <IfModule mod_weblogic.c>
            WebLogichost localhost
            WebLogicPort 7001
            debug OFF
            FileCaching OFF
            MatchExpression *
            KeepAliveSecs 540

Whenever I use different ports for site1 and site2, it runs fine. But keeping the same port does not work for me. Only the virtualhost defined first works and the other returns eorro 404. Also I found that it is called as Name based virtual hosting. The guides suggests that NameVirtualHost directive should be configured. I have also added the same.

Please help... Thank you in advance..