subdomain rewrite & setting of environment variable

Using a single web hosting account to host multiple sites

Postby richardk » Thu Jun 25, 2009 1:07 pm

Replace
Code: Select all
AliasMatch ^/clients/[^/]+/cms(/(.*))?$  "/usr/local/staff/code/cms/$2"

with
Code: Select all
AliasMatch ^/clients/[^/]+/cms/?$      "/usr/local/staff/code/cms/index.php"
AliasMatch ^/clients/[^/]+/cms/(.+)?$  "/usr/local/staff/code/cms/$1"
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nkj » Mon Jun 29, 2009 3:09 pm

Thank you very VERY much for all your help Richard! I appreciate the expertise. Everything seems to be working like a charm now. :)

-nick
nkj
 
Posts: 21
Joined: Fri May 15, 2009 11:32 am

Subdomain not working

Postby pushpinderbagga » Mon Jun 29, 2009 3:38 pm

Hi

I have the below code in my htaccess file.

Code: Select all
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.my-domain.com/ [R=301,L]

RewriteCond %{HTTP_HOST} ^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.my-domain.com/$1 [R=301,L]

RewriteRule ^([a-zA-Z0-9_-]+)$ category.php?category=$1 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)/?$ category.php?category=$1 [L,NC]


not I want to make a sub domain as http://submit.my-domain.com

my server asked me a directory so I gave it a name submitFiles and created a folder submitFiles on my public_html profile

but not when I hit the domain it tries to ping the category.php and says it doesnt exist...

am I wrong anywhere ?
pushpinderbagga
 
Posts: 36
Joined: Fri May 22, 2009 9:43 pm

Postby richardk » Mon Jun 29, 2009 5:03 pm

Try
Code: Select all
RewriteEngine Off

in /submitFiles/.htaccess.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

working

Postby pushpinderbagga » Mon Jun 29, 2009 6:15 pm

@ richardk many thanks

it worked, I did not know I had to add another htaccess and index.php in the folder before checking..

could you please guide me to any link in this forum or anywhere which can guide to the SEO steps I can take in my htaccess ?
pushpinderbagga
 
Posts: 36
Joined: Fri May 22, 2009 9:43 pm

Postby richardk » Tue Jun 30, 2009 2:46 pm

I don't have any links about SEO.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nkj » Mon Sep 14, 2009 6:33 am

Hi again Richard,

Sorry for reviving an old thread, but this is directly related to the setup that you helped me out so much with before. It seems I overlooked one aspect of the setup that doesn't seem to be working. We've established that when I user goes to:

test.sites.example.com/cms/

they are redirected to a static location (shared code) directly to the index.php file:
/usr/local/staff/code/cms/index.php

The problem I'm noticing now is that it seems like Apache is not by default using DirectoryIndex settings for normal directories in the users docroot.

This is the 'test' users docroot:
Code: Select all
/data/sites/sites.example.com/htdocs/clients/test/


In that directory, I unpack wordpress into the blog/ directory. I should be able to now access it from:
Code: Select all
http://test.sites.example.com/blog


However I get a 403 error, and in the logs it says:
Code: Select all
Directory index forbidden by Options directive: /data/sites/sites.example.com/htdocs/clients/test/blog/


I actually don't want a directory index (listing of files) i just want it to execute the index.php, or any other file I have listed in the DirectoryIndex directive. If I specify index.php at the end of the URL, it seems to call it, but then comes back with the same 403 error, as if somewhere in the code it's trying to refer to itself without the statically specificaly index.php at the end. (it shouldn't have to).

Basically, any files/directories the user puts in their docroot i want to behave like normal... ie. if they end a URL in a directory name, the index file is executed, etc.

I hope I'm explaining the situation correctly. Here is my relevant apache conf (which you helped me with previously):

Code: Select all
<VirtualHost *:80>
    ServerName sites.example.com:80
    ServerAlias *.sites.example.com:80
    ServerAdmin webmaster@example.com
    DocumentRoot /data/sites/sites.example.com/htdocs
    ErrorLog logs/sites.example.com-error_log
    CustomLog logs/sites.example.com-access_log common

    DirectoryIndex index.php index.html index.cgi

    AliasMatch ^/clients/[^/]+/(index\.php)?$ "/usr/local/staff/cmd/cmd/trunk/cmdv3/index.php"
    AliasMatch ^/clients/[^/]+/(confirmation\.php)$ "/usr/local/staff/cmd/cmd/trunk/cmdv3/confirmation.php"
    AliasMatch ^/clients/[^/]+/(contact\.php)$ "/usr/local/staff/cmd/cmd/trunk/cmdv3/contact.php"

    #AliasMatch ^/clients/[^/]+/cms(/(.*))?$  "/usr/local/staff/cmd/cmd/trunk/cmdv3/cms/$2"
    AliasMatch ^/clients/[^/]+/cms/?$  "/usr/local/staff/cmd/cmd/trunk/cmdv3/cms/index.php"
    AliasMatch ^/clients/[^/]+/cms/(.+)?$  "/usr/local/staff/cmd/cmd/trunk/cmdv3/cms/$1"
    AliasMatch ^/clients/[^/]+/flash(/(.*))?$  "/usr/local/staff/cmd/cmd/trunk/cmdv3/flash/$2"
    AliasMatch ^/clients/[^/]+/html(/(.*))?$  "/usr/local/staff/cmd/cmd/trunk/cmdv3/html/$2"
    AliasMatch ^/clients/[^/]+/slideshow(/(.*))?$  "/usr/local/staff/cmd/cmd/trunk/cmdv3/slideshow/$2"

    Options +FollowSymlinks Indexes ExecCGI

    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^(www\.)?sites\.example\.com$    [NC]
    RewriteCond %{HTTP_HOST} ^(.+)\.sites\.example\.com$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/clients/%1%{REQUEST_URI}/ -d
    RewriteRule ^/.*[^/]$ http://%{HTTP_HOST}$0/index.php [R=301,L]
    #RewriteRule ^clients/([^/]+)/(.*)$ http://%{HTTP_HOST}/$2index.php [L,R]

    RewriteCond %{HTTP_HOST} !^(www\.)?sites\.example\.com$ [NC]
    RewriteCond %{HTTP_HOST} ^(.+)\.sites\.example\.com$ [NC]
    RewriteRule ^/.*$ /clients/%1$0 [QSA,E=CMD_SITE:%1,PT,L]

</VirtualHost>


I really would appreciate any help you can offer on this. I've tried a number of things with no luck and these rewrite rules and alias rexeps are a bit beyond my grasp :)
Thanks,
nick
nkj
 
Posts: 21
Joined: Fri May 15, 2009 11:32 am

Postby nkj » Mon Sep 14, 2009 7:10 am

I also forgot to say that if I go to a URL like:

Code: Select all
http://test.sites.example.com/blog/wp-admin


it's rewritten like:

Code: Select all
http://test.sites.example.com/clients/test/blog/wp-admin/install.php


(and then get a 404)

Is there a way to fix this in a global way (not just related to the "blog" subdir, but any new subdirs a user might put in their docroot). ?

Thanks,
nick
nkj
 
Posts: 21
Joined: Fri May 15, 2009 11:32 am

Postby richardk » Mon Sep 14, 2009 10:30 am

So you only want to apply the RewriteRules to the files/directories from the AliasMatches.

Replace
Code: Select all
^/.*[^/]$

with
Code: Select all
^/(cms|flash|html|slideshow)(/.*[^/])?$


And replace
Code: Select all
^/.*$

with
Code: Select all
^/((index\.php|confirmation\.php|contact\.php)|(cms|flash|html|slideshow)(/.*)?)$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby nkj » Mon Sep 14, 2009 4:00 pm

richardk wrote:So you only want to apply the RewriteRules to the files/directories from the AliasMatches.


Not exactly, I'm assuming there still needs to be some RewriteRules in order to place the user in the correct base directory (ie. the document root for test.sites.example.com would be /data/sites/sites.example.com/htdocs/clients/test)


Replace
Code: Select all
^/.*[^/]$

with
Code: Select all
^/(cms|flash|html|slideshow)(/.*[^/])?$


And replace
Code: Select all
^/.*$

with
Code: Select all
^/((index\.php|confirmation\.php|contact\.php)|(cms|flash|html|slideshow)(/.*)?)$


I applied those changes, and now when I access:

Code: Select all
http://test.example.com/blog


I get a 404 not found, and the apache logs say:

Code: Select all
File does not exist: /data/sites/sites.example.com/htdocs/blog


It should ideally be looking in /data/sites/sites.example.com/htdocs/clients/test/blog
nkj
 
Posts: 21
Joined: Fri May 15, 2009 11:32 am

PreviousNext

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 4 guests

cron