Forum Moderators: phranque
RewriteRule gallerypage/(.*)$ https://www.example.com/gallerypage.php?autoload=$1 though the image does open correctly. For reasons that I don't understand, if I remove the domain name and use RewriteRule gallerypage/(.*)$ gallerypage.php?autoload=$1 then the clean url is shown in the address bar, but the image doesn't open. RewriteRule gallerypage/(.*)$ https://www.example.com/gallerypage.php?autoload=$1This rule redirects FROM a short pretty URL, TO a long messy one. At least, it does if there's an [R=301,L] flag that you forgot to include when posting. If not, all kinds of things can happen; at best it will be a 302 temporary redirect, but there are worse possibilities. Oh, and the $ anchor in this specific rule is superfluous. It does no harm, but only because it doesn't do anything at all. RewriteRule gallerypage/(.*)$ gallerypage.php?autoload=$1
is again missing an [L] flag, and now I begin to suspect it really is missing, which is a problem. The target in any internal rewrite ought to begin with / for root, but this is generally a non-lethal error. Is the image--or the code for opening it--in fact located at /gallerypage.php, which in turn is located at the root level? In fact, what is gallerypage.php? is it simply the php script that displays the picture?
Options -MultiViews
RewriteCond %{THE_REQUEST} \.php
RewriteCond %{QUERY_STRING} autoload=([\w-]+)
RewriteRule ^gallerypage\.php https://example.com/gallerypage/%1 [R=301,L]
Theoretically you could merge both conditions, with a single long THE_REQUEST including the capture, but then you have to worry about other parameters sneaking in, and it might get messy. RewriteRule ^gallerypage/(.+) /gallerypage.php?autoload=$1 [L]
I think technically you don't even need to pass the parameter, because the php page can look up the URI for itself (because it's an internal rewrite, not a redirect), but it feels safer to include it.