Forum Moderators: phranque
My first test was the smiles image:
# Forum test
RewriteCond %{REQUEST_URI} ^/forum/images/smiles/*
RewriteRule hxxp://forum.foo.com/images/smiles/%1 [L]
That does not work. But a quick
RedirectMatch /forum/images/smiles/icon_smile.gif hxxp://forum.foo.com/images/smiles/icon_smile.gif
does the trick. But I can not write all 100 or so smiles into the .htaccess
And after that I think I miss something with that condition, which does not work.
I try to catch the URL: hxxp://www.foo.com/forum/viewforum.php?f=45&mark=topics&sid=811c43faa3330e3c8516a4607ee20616
RewriteCond %{REQUEST_URI} ^/forum/viewforum\.php?p=$
RewriteRule hxxp://forum.foo.com/viewforum\.php?p=%1 [L]
I really got lost here :(
# Forum test
RewriteCond %{REQUEST_URI} ^/forum/images/smiles/(.*)
RewriteRule hxxp://forum.foo.com/images/smiles/%1 [R=301]
Maybe I miss an option or something:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/forum/images/smiles/(.*)
RewriteRule [forum.foo.com...] [R=301]
ErrorDocument 404 /error.php
Redirects to [forum.foo.com...]
The image file, or whatever is requested, is not 'transfered' to the var %1
Is there something like a realtime debug for mod_rewrite?
RewriteRule ^forum/viewtopic.php?p=([0-9]*)$ [forum.foo.bar...] [R=301,L]
does not work :(
<-- todo finaly understand mod_rewrite and read a book about it over x-mas!
You'll need to handle the query string separately in this case:
RewriteCond %{QUERY_STRING} ^p=([0-9]*)$
RewriteRule ^forum/viewtopic\.php$ http://forum.foo.bar/viewtopic.php?p=%1 [R=301,L]
There are several online resources about mod_rewrite and regular expressions cited in our forum charter, if you don't already have a book for the holidays. Take a quick look at the mod_rewrite documentation, and review the variables that the RewriteCond directive can examine.
Jim