homepage Welcome to WebmasterWorld Guest from 54.196.196.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Mod Rewrite to SubDirectory - Help!
A developer left us high and dry and we're stuck with this mod rewrite issu
kael21




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

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 %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_NAME} !-f
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]

 

jdMorgan




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

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.

Jim

kael21




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

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?

phranque




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

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).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved