I would like to redirect any URL string with url.html&etc to url.html only. Ok to be more specific I have some 404 not founds showing after a rewrite script on a forum. I have this so far. RewriteEngine on RewriteBase /forum/ RewriteRule /post\-([^.]+)\.html$ viewtopic.php?p=$1[L,NC] RewriteRule /post\-([^.]+)$ viewtopic.php?p=$1 [L,NC] RewriteRule /view\-poll([^.]+)\-([^.]+)$ viewtopic.php?t=$1&postdays=$2&postorder=$3&vote=viewresult [L,NC] RewriteRule /about([^.]+).html&highlight=([^.]+)$ viewtopic.php?t=$1&highlight=$2 [L,NC] RewriteRule /about([^.]+).html&view=newest$ viewtopic.php?t=$1&view=newest [L,NC] RewriteRule /about([^.]+)\-([^.]+)\-([^.]+)\-([^.]+)$ viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 [L,NC] RewriteRule /about([^.]+)\-([^.]+)$ viewtopic.php?t=$1&start=$2 [L,NC] RewriteRule /about([^.]+)$ viewtopic.php?t=$1 [L,NC] RewriteRule /about([^.]+)\.html$ viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L,NC] RewriteRule /mark\-forum([^.]+)\.html* viewforum.php?f=$1&mark=topics [L,NC] RewriteRule /updates\-topic([^.]+)\.html*$ viewtopic.php?t=$1&watch=topic [L,NC] RewriteRule /stop\-updates\-topic([^.]+)\.html*$ viewtopic.php?t=$1&unwatch=topic [L,NC] RewriteRule /forum\-([^.]+)\.html$ viewforum.php?f=$1 [L,NC] RewriteRule /forum\-([^.]+)$ viewforum.php?f=$1 [L,NC] RewriteRule /topic\-([^.]+)\-([^.]+)\-([^.]+)$ viewforum.php?f=$1&topicdays=$2&start=$3 [L,NC] RewriteRule /ptopic([^.]+)$ viewtopic.php?t=$1&view=previous [L,NC] RewriteRule /ntopic([^.]+)$ viewtopic.php?t=$1&view=next [L,NC] I have these 404's /forum/about11.html&highlight= /forum/post-24.html&highlight= /forum/about15.html& Is there an ajustment I can make here? Thanks in advance to all you coders.
RewriteRule ^forum/about([^.]+)\.html\&highlight=$ http://www.domain.com/about$1.html [R=301,L] RewriteRule ^forum/post\-([^.]+)\.html\&highlight=$ http://www.domain.com/post-$1.html [R=301,L] RewriteRule ^forum/about([^.]+)\&$ http://www.domain.com/about$1.html [R=301,L]
Wow excellent ... that is basically a fix all for a lot of the probelms of 404's What do I do with ... RewriteRule /about([^.]+).html&highlight=([^.]+)$ viewtopic.php?t=$1&highlight=$2 [L,NC] ... Does it stay or does it go?
/about([^.]+).html&highlight=([^.]+) would show up as /aboutANYTHING.html&highlight=ANYTHING How do you want that URL to look like?
Damn Wacko your a rewrite wiz... maybe you can help me out, hopefull I can do this with rewrite instead of modifying the code rewriting my urls. I'm rewriting phpBB url's like the topic starter, so I figured this isn't really thread jacking At any rate, this line: RewriteRule [.]*-vt([0-9]*) /forums/viewtopic.php?%{QUERY_STRING}&t=$1 Produces url's like: http://www.moddedmustangs.com/forums/good-deal-on-a-4-banger-vt2015.html Which is fine but when searching, a query strings gets added like: http://www.moddedmustangs.com/forums/good-deal-on-a-4-banger-vt2015.html?highlight= Is there any way to use rewrite to remove the ?highlight= if present? The url's are already being rewritten, just with the variable in them when searching. Should I try to rewrite the rewritten urls? I've tried a few rewrite commands but I can't get it right.
I can't seem to get that to work either, even tried moving it around in the order. Here is the lines in my htaccess that affect the forum rewriting: RewriteRule ^forums/.+/([^/]+\.html)$ /forums/$1 [R=301,L] RewriteRule [.]*-vf([0-9]*) /forums/viewforum.php?%{QUERY_STRING}&f=$1 RewriteRule [.]*-vp([0-9]*) /forums/viewtopic.php?%{QUERY_STRING}&p=$1 RewriteRule [.]*-vt([0-9]*) /forums/viewtopic.php?%{QUERY_STRING}&t=$1 RewriteRule [.]*-vc([0-9]*) /forums/index.php?%{QUERY_STRING}&c=$1 RewriteRule [.]*-ac([0-9]*) /forums/album_cat.php?%{QUERY_STRING}&cat_id=$1 RewriteRule [.]*-at([0-9]*) /forums/album_thumbnail.php?%{QUERY_STRING}&pic_id=$1 RewriteRule [.]*-apic([0-9]*) /forums/album_pic.php?%{QUERY_STRING}&pic_id=$1 RewriteRule [.]*-apm([0-9]*) /forums/album_picm.php?%{QUERY_STRING}&pic_id=$1 RewriteRule [.]*-full-asp([0-9]*) /forums/album_showpage.php?full=&pic_id=$1 RewriteRule [.]*-asp([0-9]*) /forums/album_showpage.php?%{QUERY_STRING}&pic_id=$1 RewriteRule [.]*-aper([0-9]*) /forums/album_personal.php?%{QUERY_STRING}&user_id=$1 Remember that: RewriteRule [.]*-vt([0-9]*) /forums/viewtopic.php?%{QUERY_STRING}&t=$1 already rewrites the url's, but in search queries I just don't want it to include the &highlight=