www.domain.com/directory => directory.domain.com

Using a single web hosting account to host multiple sites

Postby richardk » Sun Feb 18, 2007 2:44 pm

On Monday when you use the PHP i gave you, you'll be able to see the variables that get sent to the script, and you'll be able to work out what mod_rewrite (or the script) is doing wrong.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby justanothernoob » Mon Feb 19, 2007 9:19 am

I don't know if I will be able to personally work out anything, since I don't know jack about mod_rewrite. But here's the results. Check out this too.


http://www.domain.com/
Code: Select all
Array
(
)

// Variables OK.


http://www.domain.com/alabama/
Code: Select all
Array
(
    [category] => alabama/
)

//  Variables OK here too.


http://alabama.domain.com/
Code: Select all
Array
(
)

// I would expect the "[category] => alabama" variable to be here too. But surprisingly this works.


http://www.domain.com/alabama/alabama-s ... partments/
Code: Select all
Array
(
    [category] => alabama
    [title] => alabama-state-departments
)

//  Variables look OK, but don't redirect when clicked.


http://alabama.domain.com/alabama
Code: Select all
Array
(
    [category] => alabama
    [title] => alabama
)

// what the heck??


http://alabama.domain.com/alabama-public-records/
Code: Select all
Array
(
    [category] => alabama
    [title] => alabama-public-records
)

// Now see, this  Variable looks right, but doesn't work...  I'm beginning to think the script doesn't display the correct data on the page because when the category is placed at the beginning of the URL, as a subdomain it's no longer a value of the query? Or does PHP extract query values before mod_rewrite?


http://alabama.domain.com/alabama/alaba ... c-records/
Code: Select all
Array
(
    [category] => alabama
    [title] => alabama
    [commentspage] => alabama-public-records
)

// This Variable is not right. The comments page should just be a numerical value. /alabama/alabama-public-records/2/ for example.


Edit: I've temporarily put the .htaccess file back to the way it was originally, since certain people wish to see the site working.
justanothernoob
 
Posts: 8
Joined: Mon Feb 12, 2007 9:11 am

Postby richardk » Mon Feb 19, 2007 2:09 pm

alabama.domain.com/alabama ... what the heck??

Why have you go two "alabama"s? I though you wanted to move the alabama, not repeat it. What were you expecting?

alabama.domain.com/alabama-public-records/ ... Now see, this Variable looks right, but doesn't work... I'm beginning to think the script doesn't display the correct data on the page because when the category is placed at the beginning of the URL, as a subdomain it's no longer a value of the query? Or does PHP extract query values before mod_rewrite?[/code]

The PHP should get it's values from the $_GET array, which is what you're seeing. Maybe it doesn't, ask the script author.

alabama.domain.com/

Ah. Replace the ".*" in the first RewriteRule with ".+".

Variables look OK, but don't redirect when clicked.

You want it to redirect to where, the sub domain?

// This Variable is not right. The comments page should just be a numerical value. /alabama/alabama-public-records/2/ for example.

Replace
Code: Select all
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?category=%2&title=$1&commentspage=$2 [L]

with
Code: Select all
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?category=%2&title=$1&commentspage=$2 [L]

and replace
Code: Select all
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?category=$1&title=$2&commentspage=$3 [L]

with
Code: Select all
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)/?$ index.php?category=$1&title=$2&commentspage=$3 [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby justanothernoob » Mon Feb 19, 2007 3:00 pm

richardk wrote:Why have you go two "alabama"s? I though you wanted to move the alabama, not repeat it. What were you expecting?


Just as a test. I noticed that all of my links are absolute, such as:

Code: Select all
<a href="/alabama/alabama-public-records/">link</a>


but this will no longer work if the page is a subdomain. :x

richardk wrote:You want it to redirect to where, the sub domain?


Actually, if the user clicks on a link while inside the subdomain homepage and it redirects them to that corresponding page back on the main site, thats okay. As long as they don't hit 404 on the subdomain index page its fine by me.
justanothernoob
 
Posts: 8
Joined: Mon Feb 12, 2007 9:11 am

Postby richardk » Mon Feb 19, 2007 3:10 pm

Actually, if the user clicks on a link while inside the subdomain homepage and it redirects them to that corresponding page back on the main site, thats okay.

Try
Code: Select all
<IfModule mod_php4.c>
    php_value session.use_trans_sid 0
</IfModule>

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain\.com$ [NC]
Rewriterule ^(.*)$ http://www.domain.com/%1/$1 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} !^$ [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule .* - [L]

RewriteRule ^([a-z_]+)/([^/]+)/?$          /index.php?category=$1&title=$2                 [L]
RewriteRule ^([a-z_]+)/([^/]+)/([0-9]+)/?$ /index.php?category=$1&title=$2&commentspage=$3 [L]
RewriteRule ^([a-z0-9_-]+)/([0-9]+)/?$     /index.php?category=$1&articlespage=$2          [L]
RewriteRule ^(.*[^/])/?$                   /index.php?category=$1                          [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby justanothernoob » Mon Feb 19, 2007 3:57 pm

Tried, failed. Sigh. You know I'm beginning to think that perhaps I should take the scripts authors advice. Which was that trying to do this is not a good idea. :(
justanothernoob
 
Posts: 8
Joined: Mon Feb 12, 2007 9:11 am

Postby richardk » Tue Feb 20, 2007 10:11 am

Try replacing %1 with %2. Then it should redirect correctly.

You know I'm beginning to think that perhaps I should take the scripts authors advice. Which was that trying to do this is not a good idea.

The design of the script shouldn't break the redirect (the last mod_rewrite). But it could be the cause of the other errors.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Previous

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 17 guests

cron