Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Mod Rewrite to SubDirectory - Help!

A developer left us high and dry and we're stuck with this mod rewrite issu



7:05 am on Nov 24, 2007 (gmt 0)

5+ Year Member

I've looked through the forum and couldn't find just the right post for this, so I'm helping someone can help.

We hired a developer to accomplish the task, but he left us half way and still cannot reach him. Here's what we're trying to accomplish.

Our site has multiple subdomains which are based around city locations. We want the search results that link to the detail pages to not only write the detail page in a SEF format, but link and display the detail page within it's appropriate subdomain.

The subdomain should not have to be hard defined, whereby we may create other subdomains in the future, and don't want to have to update the .htaccess file.

So if a user searches on the city of "Whistler", the detail page should display under http://whistler.example.com/SEF_URL

Problem is the developer last left off saying the problem is with a 302 redirect which redirects the detail page back to the root directory and not the subdomain directory.

I've pasted the mod rewrite below.

Can anyone help? Keey in mind I'm not very technical here.

The .htaccess file in the root shows the below. Below this, is the .htaccess file used in the subdomain folder.

Root .htaccess

Options +FollowSymLinks
# Disable directory browsing
Options -Indexes
RewriteEngine on
# RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?whistler\.example\.com$
RewriteRule ^(.*)/([0-9]+)[-/].*.htm$ lease_show.php?Lease=$2 [L,NC]
RewriteRule ^(.*)/([0-9]+)[-/].*.htm$ lease_show.php?Lease=$2 [L,NC]
RewriteRule ^(lease¦BigWhite¦Pemberton¦Whistler¦Squamish¦SunPeaks)/([0-9]+)[-/].*.htm$ lease_show.php?Lease=$2 [L,NC]
RewriteRule ^platinum_leases.htm$ platinum_leases.php [L,NC]
RewriteRule ^featured_leases.htm$ featured_leases.php [L,NC]
RewriteRule ^hot_lease_car.htm$ hot_lease_car.php [L,NC]

Subdomain .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteBase /whistler
RewriteCond %{HTTP_HOST} ^(www\.)?whistler\.example\.com$
RewriteRule ^(.*)/([0-9]+)[-/].*.htm$ lease_show.php?Lease=$2 [L,NC]
# Disable directory browsing
Options -Indexes
RewriteRule ^http://whistler.example.com/lease_show.php?Lease=$2%{QUERY_STRING} http://www.example.com/lease_show.php?Lease=$2%{QUERY_STRING} [L,NC]
# rewriteRule ^foo\.html$ http://www.example.com/index.php
# RewriteRule ^whistler/+(.*)/([0-9]+)[-/].*.htm$ lease_show.php?Lease=$2 [L,NC]
# RewriteRule ^(lease¦BigWhite¦Pemberton¦Whistler¦Squamish¦SunPeaks)/([0-9]+)[-/].*.htm$ lease_show.php?Lease=$2 [L,NC]

Can anyone see the problem or help?

[edited by: jdMorgan at 3:50 pm (utc) on Nov. 24, 2007]
[edit reason] Example.com -- Please see Terms of Service. [/edit]


3:52 pm on Nov 24, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

That code is pretty awful, with several errors and inefficiencies. But the developer is correct, in that the problem is in your script, not in the .htaccess code.

There are no redirects in this code, and as a result, it can neither redirect nor change the current subdomain.



7:08 pm on Nov 24, 2007 (gmt 0)

5+ Year Member

Thats for some insight. Appreciated.

When you say the problem is within the script, which script would this be?

Also, I read somewhere that this may happen if you use =$2 versus =%2....does that make a difference?


6:35 am on Nov 25, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

welcome to WebmasterWorld [webmasterworld.com], kael21!

the rewritecond(s) only apply to the following rewriterule.
the $n's apply to a given rewriterule's matched group(s) (parentheses in the regexp).
the %n's apply to group matches in the rewritecond(s).


Featured Threads

Hot Threads This Week

Hot Threads This Month