Reputation: 4360
My .htaccess
file
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^the-image-([A-Za-z0-9]+)-([A-Za-z0-9+]+)/?$ images/userfolder/$1/$2 [NC,L] #Loading Images
And in my PHP page
<img src='./the-image-$username-$image_id' alt='User Image' />
My aim is to load the image for each user based upon his username and Image ID.
The username is stored under $username
and Image ID under $image_id
variables. And the images will be located under images/userfolder/username/image.jpg
But the images are not getting loaded. What is the error in my syntax?
Note: The Image ID variable holds both the image name and it' extension. Example : 1.jpg
Upvotes: 2
Views: 974
Reputation: 11799
You may try this instead:
RewriteRule ^the-image-([^-]+)-([^-]+)/?$ images/userfolder/$1/$2 [NC,L]
Upvotes: 1
Reputation: 111
^the-image-([A-Za-z0-9]+)-([A-Za-z0-9+]+)/?$
The forward slash at the end is not escaped. Try changing the regex this way
^the-image-([A-Za-z0-9]+)-([A-Za-z0-9+]+)\/?$
Or you can just remove it if you never expect any forward slash after the $image_id
^the-image-([A-Za-z0-9]+)-([A-Za-z0-9+]+)$
Upvotes: 0