You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Eskil Kvalnes <es...@lynweb.no> on 2004/03/03 14:08:18 UTC

[users@httpd] mod_rewrite: rewriterule assistance

Hi,

This is what I'm trying to achieve using mod_rewrite:

http://sub.foo.com/Bakgrunner/Razorart_Wallpapers/ =>
index.php?folder=/Bakgrunner/Razorart_Wallpapers/
http://sub.foo.com/Bakgrunner/ => index.php?folder=/Bakgrunner/
http://sub.foo.com/Bakgrunner/Razorart_Wallpapers/Chemlab.jpg =>
index.php?folder=/Bakgrunner/Razorart_Wallpapers/&image=Chemlab.jpg
http://sub.foo.com/Picture_031.jpg =>
index.php?folder=/&image=Picture_031.jpg
http://sub.foo.com/Bakgrunner/Razorart_Wallpapers/Page_2/ =>
index.php?folder=/Bakgrunner/Razorart_Wallpapers/&page=2

Folder can be multiple directories (/dir1/dir2/dir3/dir4/etc/), but it can
also be only one, like /.
Image is always last in the url, preceded by a folder.
Page is also always last, in this format: Page_x/, preceded by a folder

Contents of .htaccess:

RewriteEngine on
RewriteBase /
Options +FollowSymlinks -Indexes
RewriteRule ^.htaccess$ - [F]
RewriteRule css/style.css$ css/style.css [L]
RewriteRule images/(.*)$ images/$1 [L]
RewriteRule gallery/(.*)$ gallery/$1 [L]
RewriteRule ^(.*)/(.*)/Page_(.*)$ index.php?folder=$1&image=&page=$3
RewriteRule ^(.*)/(.*)$ index.php?folder=$1&image=$2

When accessing
http://sub.foo.com/Bakgrunner/Razorart_Wallpapers/Chemlab.jpg, everything
works fine:

Array
(
    [folder] => Bakgrunner/Razorart_Wallpapers
    [image] => Chemlab.jpg
)

Same when accessing http://sub.foo.com/Bakgrunner/Razorart_Wallpapers/:

Array
(
    [folder] => Bakgrunner/Razorart_Wallpapers
    [image] =>
)

but when I access http://sub.foo.com/Bakgrunner/Page_2/, Page_2/ gets
translated as a folder:

Array
(
    [folder] => Bakgrunner/Page_2
    [image] =>
)

instead of:

Array
(
    [folder] => Bakgrunner
    [image] =>
    [page] => 2
)

And when accessing http://gallery.hypothetic.net/Picture_031.jpg, I get a
HTTP 404.

Thanks for your time,
Eskil Kvalnes



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org