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

Apache Web Server Forum

    
Problem Removing a Folder from a subdomain. Simple Rewrite Condition
I have a subdomain with folders inside. We want to kill a directory.
acimag

5+ Year Member



 
Msg#: 4055285 posted 4:47 pm on Jan 6, 2010 (gmt 0)

We run a website and have a domain that has a subdomain. We want to kill one of the directorys and re-route all that traffic back to the root of the directory.

I tried.

RewriteCond %{HTTP_HOST} !^longisland\.domain\.com\Xbox_Services\$ [NC]
RewriteRule ^(.*)$ [longisland.domain.com...] [R=304,L]

AND

RedirectMatch 301 [longisland.example.com...] [longisland.example.com...]

AND

RewriteRule ^Xbox_Services/(.*) [longisland.example.com...] [R=301,L,QSA]

AND

Redirect 301 /Xbox_Services/(.*) [longisland.example.com...]

=============================
All of the above Do not work.
=============================
I'm sure looking at it your just saying to yourself NOOB... We'll help me out.

FYI I know in previous post you say be as descriptive as possible.

Well.. Inside of longisland.example.com/Xbox_Services we have subdomains as well.
Meaning...

longisland.example.com/Xbox_Services/Overheat
longisland.example.com/Xbox_Services/RedRing
longisland.example.com/Xbox_Services/Whatever
longisland.example.com/Xbox_Services/Overheat/TowelTrick

We need to just get rid of everything with the condition of Xbox Service

Ideally I want this to work because We are killing other subfolders as well:
RewriteCond %{HTTP_HOST} !^longisland\.domain\.com\Xbox_Services\$ [NC]
RewriteRule ^(.*)$ [longisland.domain.com...] [R=304,L]

 

jdMorgan

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



 
Msg#: 4055285 posted 7:03 pm on Jan 6, 2010 (gmt 0)

A review of the regular-expressions tutorial cited in our Apache Forum Charter would seem to be in order. Most of the directives posted above contain one or more 'tiny' little errors that completely stop the code from working. And *that* is the most important thing to learn about writing server configuration code: It must be perfect.

In addition to these tiny errors, there's also some misunderstanding of server variable scope in evidence: For example, HTTP_HOST contains only the requested hostname, possibly with a port number appended. It does not contain any part of the requested URL-path. Conversely, the URL-paths examined by RedirectMatch and RewriteRule contain only the URL-path, and do not contain the requested protocol or domain name.

After looking through all those attempts, the following two lines were most salvageable:

RedirectMatch 301 /Xbox_Services/ http://longisland.example.com/
-or-
RewriteRule ^Xbox_Services/ http://longisland.example.com/ [R=301,L]

Either of those two lines should work, assuming that this code goes into the /.htaccess file in a separate root directory for longisland.example.com, that you completely flush (delete) your browser cache after making any changes to your server config code, that the mod_alias and mod_rewrite modules are available, that no other modules, rules, or directives (e.g. MultiViews or AcceptPathInfo) are interfering, and that you've got the required set-up directives already in place if you're using mod_rewrite. That's a fair number of assumptions, all of which need to be confirmed.

Jim

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