mod_rewrite scalable?

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

mod_rewrite scalable?

Post by kaYak »

Hi,

I'm developing a site where our system allows users to create simple sites. I'm going to set it up where all of the pages are hosted in a database (since they are solely HTML) and are completely dynamic. Therefore, I have mod_rewrite setup so that it takes a file path and sends it to a PHP file. This must be done for the dynamic files so they appear static but we also want the users to be able to upload images for use on their site. I'm considering mod_rewriting these physical files so that the directories and paths seem to match and so they also appear to be coming from their site and not ours. My friend says that this would not scale and it would eventually use too many server resources for processing the mod_rewrite. Although, all the mod_rewrite would be doing is passing the path to a single php file.

Is mod_rewrite scalable to use for all of the files or should I just use it for the files I absolutely need to? I thought it would be nice to make it look the files are all from the same domain. My friend is proposing linking to the files where everyone's files are all in one directory on our server (our domain, not the client's).

I think it would be better to use mod_rewrite for everything if it is scalable. Any thoughts?

Thanks,
Kyle
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

It's generally impractical to try to manage multiple sites straight through mod_rewrite. In fact, your entire proposal seems a bit impractical. Why can't these files just exist on the server?
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

Post by kaYak »

The setup is similiar to WordPress.com where everything is highly dynamic with the possibility of subdomains and domains being linked to accounts. Although, it is not blog hosting.

Oh, and to clarify, the files that are not dynamic do exist on the server as physical files. Although, the way I would like it is that their true paths on the server are not revealed.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Well, if you insite on doing it that way, you could send them all to a central PHP file which would then handle all of the requests instead of all through mod_rewrite. Then, you could use the database to assist you.
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

Post by kaYak »

Which I was planning on anyways. Right now a page request at http://www.samplesite.com/about_us/contact.html will be sent to a PHP file that looks up that page in the database under the category of "about_us" for the client with the domain name samplesite.com. It then grabs that page HTML and works with it to output it with whatever else. Although, if it's not an html file I was thinking it could look it up in the database under a files table and get the physical location on the server and then push the file through the browser with PHP so that the actual location is masked and everything is clean and looks the same across all of the site's content.

So, the big question was: How much processing power does using mod_rewrite to handle all of the files and sending the requests to a php file take over using Apache's regular file system to handle physical files?

EDIT: My friend was proposing just linking to their files on our server like oursite.com/userfiles/95334/image.gif, so that they go from theirsite.com to oursite.com and all of the images are hosted from our domain and not theirs.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Well, I think you are thinking too much in terms of mod_rewrite. Stop. :P

From the sound of things, your concern is the database. Files are more efficient outside of the database, not being pulled from it.
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

Post by kaYak »

The only stuff I'd be pulling from the database is the content for all of the HTML files. That is fed into the layout. Real files like images or PDF files are stored physically on the server (outside of the database). Mod_rewrite would only be masking their true location on the server. Files are not being pulled from the database at all.

The concept of content being taken from the database is not going to change. So my question is: Is it worth it to mask the URLs of the user's images and non-HTML files to keep the paths clean and consistent across the site and so the images are not coming from another domain, or does this use too much processing power with the mod_rewrite?
Last edited by kaYak on Sun Jul 01, 2007 6:28 pm, edited 1 time in total.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Wasn't your question whether or not to store images in the database or remotely on their server?
kaYak
Forum Commoner
Posts: 65
Joined: Mon Feb 02, 2004 2:43 pm
Location: USA

Post by kaYak »

Sorry, no, what I meant was is it worth masking all of the files using mod_rewrite. Right now mod_rewrite is sending the path to a php file which handles it. It doesn't HAVE to do that for non-dynamic files as they are real files and are not generated on the fly. So, is it too much work for the server to mask the file paths or should I do this to keep it clean and nice looking?

The images on somesite.com/index.html could be coming from oursite.com/users/24343/logo.gif, header.gif, etc.

OR they could come from theirsite.com/images/logo.gif using mod_rewrite as they could be coming from the location above but this would be masked or they could just have a database row where their actual location is stored and then looked up to get the file.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I would just not use mod_rewrite on files that already exist and let them be.
Post Reply