Forum Moderators: phranque
Example url: http://www.example.com/user.php?USERNAME&item=ITEMNAME
Currently works: http://www.example.com/USERNAME
Doesn't quite work: http://www.example.com/USERNAME/ITEMNAME
Here are the rewrites that I am using:
RewriteRule ^([a-z0-9_\-]+)$ /user.php?user=$1 [NC,L]
RewriteRule ^([a-z0-9_\-]+)/([a-z0-9_\-]+)$ /user.php?user=$1&item=$2 [NC,L]
RewriteRule ^([a-z0-9_\-]+)/$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /user\.php\?user=([^&]+)&item=([^&]+)\ HTTP/
RewriteRule ^user\.php$ http://www.example.com/%1/album/%2? [R=301,L]
I am really not sure why this is resulting in the page not fully displaying. If someone knows I would appreciate the help!
You have a couple of choices: One is to use server-relative or canonical URLs to reference those included objects. The other is to detect URL requests for images, css, JS, and any other objects which are to be shared by all virtual directory levels, and rewrite them to remove the extra directory levels, or point them all to a common directory path.
Page-relative link: <img src="images/logo.gif">
Page-relative link: <img src="../images/logo.gif">
Server-relative link: <img src="/images/logo.gif">
Canonical link: <img src="http://www.example.com/images/logo.gif>"
Jim