apache http server: rewrite rule: how to make a basedir change?
This page:
http://test/subdira/subdirb/
has relative links, like this:
<script type="text/javascript" src="res/ext-base.js"></script>
The problem is that the directory res/ is not in /subdira/subdirb/ but in another directory (/js/ext-3.3.1/cm). So I’m wondering how to change the basedir (or maybe another solution).
So if I try this rule:
RewriteRule ^/$ /js/ext-3.3.1/cm/index.html [QSA,L]
I may now be able to call the “base” url without ‘subdira/subdirb/
‘ like this:
http://test/
but… if I do this, this relative link:
<script type="text/javascript" src="res/ext-base.js"></script>
doesn’t work anymore because it tries to access the /res/ext-base.js, not the good one.
Any idea how I could do?
Ok I found it here:
(Section “Search pages in more than one directory”)
http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html
I’ve taken the opposite side: test if the file is in the subdirectory, if so, stop and go ahead:
RewriteCond %{DOCUMENT_ROOT}/js/ext-3.3.1/cm/%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /js/ext-3.3.1/cm/$1 [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/js/ext-3.3.1/cm%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /js/ext-3.3.1/cm$1 [QSA,L]
it works o/
Check more discussion of this question.
Related posts:
- Apache : Rewrite rule to change a file path
- Apache rewrite rule (that already works) optimization : any good advice?
- Is this an unsafe Apache Rewrite Rule?
- Apache Rewrite: How to write a rule based on domain name (instead of HTTP_HOST)?
- How do I make a mod_rewrite rule that uses the sub-domain name to rewrite the URL?
Leave a comment
Recent Posts
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
- Can Windows RDC admin users be immune from being kicked?
- Domain Administrators account policy (After PCI audit)
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





