Forum Moderators: phranque
www.mysite.com/stuff/stuff.php?items=5
to
www.mysite.com/stuff/5
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} (/stuff/)
RewriteRule ^stuff/([^/]+) /stuff.php?items=$1 [L]
However, when I do this none of the images on the page carry over. All the images are in the folder www.mysite.com/images/. I've tried just doing RewriteCond %{REQUEST_URI} (/images/) as well but that doesn't work...the whole process confuses me. Any help?
[edited by: StoutFiles at 7:05 pm (utc) on June 6, 2008]
The browser resolves the URL for the image based on the URL of the page if the link to that image is relative.
Start the URL for the images with a leading slash to make it count from the root.
Make sure that your rewrite only rewrites for html files, or does not rewrite for a specific folder, like the /images/ folder.
RewriteEngine on
RewriteRule ^(.*).html$ http://www.example.com/foldername/scriptname.php?file=$1 [QSA]
Shouldn't there be a $ at the end of the first half of your RewriteRule? And how about if you use the fully qualified URL in the second half?
-> Whoops, posted after the reply came.
Start the URL for the images with a leading slash to make it count from the root.
>>Feel kind of stupid now.
I sure do, I have no idea how I got this thing working. If it breaks I'm a goner. :)
[edited by: Marcia at 7:55 pm (utc) on June 6, 2008]
Be aware that by including the "fully-qualified URL" in your RewriteRule, you are forcing a 302 redirect to "scriptname.php" -- likely exposing "/scriptname.php" to the search engines, and likely defeating the original purpose of the rewrite. (Check for the 302 with a server headers checker).
For an internal rewrite, correct syntax would be:
RewriteEngine on
RewriteRule ^(.+)\.html$ /foldername/scriptname.php?file=$1 [QSA,L]
Jim