Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
mod_rewrite "zero or more of..." Regex
Old 12-21-2009, 03:17 PM Question mod_rewrite "zero or more of..." Regex
Skilled Talker

Posts: 76
Name: Nick Cousins
Location: Northern Ireland
Trades: 0
I'm building a web application that hosts multiple websites using one codebase, and loading all of the content from a database based on the URL used to access it.

So I configure all my domains to point to one IP address, and the server treats all requests the same (i.e. no virtual hosts) - but my PHP script loads different sites according to the domain passed.

When in development the system is designed to use a parameter passed in the URI as the domain instead of the actual hostname:

e.g. example.com would be accessed by typing in http://development.server.com/example.com

This means we can try out sites without them actually being set live.

The issue I have is that the HTACCESS files on the development and live servers need to be different because I can't get the standard Regex "Zero or more of..." principle to work in mod_rewrite.

This rule rewrites http://development.server.com/example.com/page to what would normally be http://example.com/page:
ReWriteRule ^([a-zA-Z0-9._-]*)\/([^\/\.]+)\/?$ /site.php?domain=$1&p=$2 [NC,L,NS]

Works fine at http://development.server.com/example.com
or if I access http://live.server.com/example.com

However - if I point example.com to the IP of the live server it will not work and I have to change all of the rewrites to:
ReWriteRule ^\/([^\/\.]+)\/?$ /site.php?domain=$1&p=$2 [NC,L,NS]

I'm obviously doing something ridiculously stupid here - anyone got any ideas what it might be?
__________________
Join
Please login or register to view this content. Registration is FREE


Knowledge is power. Never underestimate the power of stupid people in large numbers.


Last edited by HandCoder; 12-21-2009 at 04:10 PM..
HandCoder is offline
Reply With Quote
View Public Profile Visit HandCoder's homepage!
 
 
Register now for full access!
Old 12-21-2009, 03:35 PM Re: mod_rewrite "zero or more of..." Regex
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,381
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
probably using RewriteCond %{the_request} would be better than using ReWriteRule

Though I will admit that Apache and .htaccess is not my strong point
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to mod_rewrite "zero or more of..." Regex
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10373 seconds with 12 queries