mod_rewrite add and switch directory

Posted by Markus on Server Fault See other posts from Server Fault or by Markus
Published on 2009-12-29T14:40:52Z Indexed on 2010/03/16 16:01 UTC
Read the original article Hit count: 177

Filed under:
|

How to change the url pattern with mod_rewrite first from

domain.de/images/myfile.jpg

to

domain.de/directory/images/myfile.jpg

and then finally to

domain.de/images/directory/myfile.jpg

My rules so far

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.de$
RewriteCond %{REQUEST_URI} !^\/directory
RewriteRule ^(.*)$                                              directory/$1 [NC]


RewriteCond %{REQUEST_URI} ^\/directory\/images
RewriteRule ^\/directory\/images\/(.*)$                       images/directory/$1 [qsappend,L]

The first part is working but the exchange of directory fails

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about apache