使用MOD_REWRITE后,是否需要修改网页中的链接?

I'm in process of cleaning my URLs.

Say I have a URL http://www.example.com/index.php?id=12345&name=some-name

I just changed it to look better using mod_rewrite

http://www.example.com/blog/12345/some-name

Now the pain is the page index.php is not loading any images, css files and the anchor links are all broken.

Location of my image is http://www.example.com/images/12345/some-image.jpg

I have used relative paths through out my site.

Now do I need to change links on all my pages ? Can .htaccess do some trick for me ? Please help.

Here is my .htaccess-

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^blog/(.*)/$ index.php?id=$1 [NC,L]

RewriteRule ^blog/(.*)/(.*)$ index.php?id=$1&name=$2 [NC,L]

Look at the second line that I added.

RewriteEngine On
RewriteRule \.(css|jpe?g|gif|png|js|css|htm|html|mp3|wav|ico)$ - [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^blog/(.*)/$ index.php?id=$1 [NC,L]
RewriteRule ^blog/(.*)/(.*)$ index.php?id=$1&name=$2 [NC,L]

This basically says if you see this extension in the URL, just pass it straight to the file.

RewriteCond applies to only the next rule and not to all rules below. Your second rule is not looking to avoid directories and files which exist. Try this

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^blog/(.*)/$ index.php?id=$1 [NC,L]


RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^blog/(.*)/(.*)$ index.php?id=$1&name=$2 [NC,L]

Ahh...!

I just added this little line in my header and it resolved all my problems :)

<base href="http://example.com/ />

Now I'm like... Why the heck did my mind take so long to think this one :)