473,473 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

mod_rewrite rules for live site

* I'm trying to work out some rewrite rules that should do the
following:

case 1: a request to mysite.com:
rewrite http://www.mysite.com/files/sheets.ppt
to http://www.mysite.com/sites/default/files/sheets.ppt

case 1 - n: a request to othersite.com:
rewrite http://www.othersite.com/files/sheets.ppt
to http://www.othersite.com/sites/other...les/sheets.ppt

So, if a request comes in to mysite.com, /files/-urls need to be
rewritten do /sites/default/files/sheets/ppt, since mysite is the
default website on the server. Surfing to a file on any other website
that is hosted on the server, needs to be rewritten to /sites/
<name_of_site>/files/sheets.ppt

Sheets.ppt is of course just an example of a file file.

* I first tested my CMS (for which I need these rules) on my own
little server @home, and found these rules to be working OK after
spending hours on forums on apache and mod_rewrite:

# http://localhost/mysite/files/* /mysite/sites/default/files/*
RewriteCond %{REQUEST_URI}-default ^/mysite/.+-(default)$ [NC,OR]
# http://loclahost/<othersite>/files/* /<othersite>/sites/
<othersite>/files/*
RewriteCond %{REQUEST_URI}-default ^(.+)(default)$ [NC,OR]

But now I have no clue on where to begin anymore, since it has been a
long time I researched mod_rewrite. Could somebody help me out? Any
help is appreciated :-)

Oct 27 '07 #1
3 1829
On Oct 27, 1:22 pm, dennis.spreng...@gmail.com wrote:
* I'm trying to work out some rewrite rules that should do the
following:

case 1: a request to mysite.com:
rewritehttp://www.mysite.com/files/sheets.ppt
tohttp://www.mysite.com/sites/default/files/sheets.ppt

case 1 - n: a request to othersite.com:
rewritehttp://www.othersite.com/files/sheets.ppt
tohttp://www.othersite.com/sites/othersite/files/sheets.ppt

So, if a request comes in to mysite.com, /files/-urls need to be
rewritten do /sites/default/files/sheets/ppt, since mysite is the
default website on the server. Surfing to a file on any other website
that is hosted on the server, needs to be rewritten to /sites/
<name_of_site>/files/sheets.ppt

Sheets.ppt is of course just an example of a file file.

* I first tested my CMS (for which I need these rules) on my own
little server @home, and found these rules to be working OK after
spending hours on forums on apache and mod_rewrite:

#http://localhost/mysite/files/*/mysite/sites/default/files/*
RewriteCond %{REQUEST_URI}-default ^/mysite/.+-(default)$ [NC,OR]
#http://loclahost/<othersite>/files/* /<othersite>/sites/
<othersite>/files/*
RewriteCond %{REQUEST_URI}-default ^(.+)(default)$ [NC,OR]

But now I have no clue on where to begin anymore, since it has been a
long time I researched mod_rewrite. Could somebody help me out? Any
help is appreciated :-)
You're making it harder than you need to. Just use an alias:

Alias /files <path to the webroot>/sites/default/files

Oct 27 '07 #2
You're making it harder than you need to. Just use an alias:
>
Alias /files <path to the webroot>/sites/default/files
I would really like it to work with mod_rewrite rules in .htaccess, so
that I don't have to create a new alias for every website I might add
in the future. So if you understand mod_rewrite, please throw me a
bone here :-)

Oct 27 '07 #3
de**************@gmail.com wrote:
* I'm trying to work out some rewrite rules that should do the
following:

case 1: a request to mysite.com:
rewrite http://www.mysite.com/files/sheets.ppt
to http://www.mysite.com/sites/default/files/sheets.ppt

case 1 - n: a request to othersite.com:
rewrite http://www.othersite.com/files/sheets.ppt
to http://www.othersite.com/sites/other...les/sheets.ppt

So, if a request comes in to mysite.com, /files/-urls need to be
rewritten do /sites/default/files/sheets/ppt, since mysite is the
default website on the server. Surfing to a file on any other website
that is hosted on the server, needs to be rewritten to /sites/
<name_of_site>/files/sheets.ppt

Sheets.ppt is of course just an example of a file file.

* I first tested my CMS (for which I need these rules) on my own
little server @home, and found these rules to be working OK after
spending hours on forums on apache and mod_rewrite:

# http://localhost/mysite/files/* /mysite/sites/default/files/*
RewriteCond %{REQUEST_URI}-default ^/mysite/.+-(default)$ [NC,OR]
# http://loclahost/<othersite>/files/* /<othersite>/sites/
<othersite>/files/*
RewriteCond %{REQUEST_URI}-default ^(.+)(default)$ [NC,OR]

But now I have no clue on where to begin anymore, since it has been a
long time I researched mod_rewrite. Could somebody help me out? Any
help is appreciated :-)

And your PHP question is?

Try an appropriate newsgroup - such as alt.apache.configuration.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Phil Powell | last post by:
http://www.sitepoint.com/article/910/2] How can it be possible to use Apache's mod_rewrite module in such a way as to dynamically feed it variable information into the "RewriteRule" option? I...
1
by: Westcoast Sheri | last post by:
Hello. How do I do this: If a visitor types in any number after my url, I want mod_rewrite to convert it to my url/anotherpage.html?number=number_visitor_typed Example: ...
2
by: Geradeaus | last post by:
I use htaccess to rewrite the url using the following rules : RewriteRule ^(+)/(+)/(+)?$ index.php?lang=$1&page=$2&id=$3 The only problem I have is when http://www.domain.com/admin is given,...
11
by: joelbyrd | last post by:
I have a people-networking type site in which each user has their own profile page, with their user id encoded. So, for example, the web address of their page might look like...
0
by: bradvanwick | last post by:
I've got URLs that look like: www.mysite.com/template.php?id=pagetitle www.mysite.com/template.php?id=folder/pagetitle I want the URLs to look like: www.mysite.com/pagetitle...
7
by: k3pp0 | last post by:
Hello. I'm trying to make use of "pretty URLs" with Apache's rewrite module. Here's what I want: http://foo.bar/index.php?download should be replaced with
11
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
With Apache's mod_rewrite module I can keep *.php files and load them as *.html files: # Make http//example.com/foo/bar.html load /home/site/foo/bar.php RewriteEngine On RewriteRule...
2
by: LC's No-Spam Newsreading account | last post by:
On Tue, 7 Oct 2008, Grant wrote: I carefully RTFM, but can't find an example like my case. What is the " fake directory cgi option" ? (in general I avoid using /cgi-bin or personal...
2
by: theoni | last post by:
I need some help with something I am trying to solve here and cannot find anything online I need to mod_rewrite to redirect with 301 to remove duplicate content from google the following: ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.