Directory Rewrite

New to mod_rewrite? This is a good place to start.

Directory Rewrite

Postby psuhiker » Mon Jun 01, 2009 3:12 pm

For security reasons, I remapped my directory structure to display all urls as follows:

www.domain.com/system/index.php to www.domain.com/index.php

This works almost perfectly, except image uploads by registered users are still not mapping the correct directory. When images are uploaded, they are placed here: www.domain.com/useruploads, however, when viewing a broken image, the system wants to look for the image in www.domain.com/system/useruploads. How can I get the system images folder to look in the root directory instead?
psuhiker
 
Posts: 3
Joined: Mon Jun 01, 2009 3:09 pm

Postby richardk » Tue Jun 02, 2009 10:46 am

Post your mod_rewrite.

A condition such as
Code: Select all
# If it's not /useruploads
RewriteCond %{REQUEST_URI} !^/useruploads(/.*)?$ [NC]

will probably work.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Thanks

Postby psuhiker » Tue Jun 02, 2009 12:59 pm

This was exactly the fix. Here's the whole shebang for those who could use the reference. This was to 1. allow the CMS to run in a /system/ directory but display as though it were in the root direcory, and 2. Allow for the image uploads to look in the root, instead of in the /system/ folder.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

# If it's not /useruploads
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/useruploads(/.*)?$ [NC]
RewriteRule ^(.*)$ /system/$1 [L]
psuhiker
 
Posts: 3
Joined: Mon Jun 01, 2009 3:09 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 111 guests

cron