Reputation: 7490
Iv seen load of htaccess examples and generators to rewrite a url, however I need to put in a 301 redirect for a web app which used to be on a subdomain, but is now in a directory, its also moved from .asp tp .php
the basic redirect is
http://sub.domain.com/twforum/forum.asp?FORUM_ID=
redirects to
http://domain.com/forum/viewforum.php?f=
this part i can do, but i dont know how to handle the id (forum id) that will be passed in the url, I DONT want the forum id to be rewritten to a url friendly on, just for it to be carried over/redirected
I assume i need to mod_rewrite the query part.
heres what iv got
RewriteEngine On
RewriteCond %{QUERY_STRING} ^http://sub.domain.com/twforum/forum.asp?FORUM_ID=1$ [NC]
RewriteRule http://domain.com/forum/viewforum.php\?f=1$ [L,R=301]
can anyone see any clear errors there or know of a better way?
thanks
Upvotes: 0
Views: 504
Reputation: 12727
%{QUERY_STRING}
does not contain the whole of the URL. Just the query setting part. e.g. FORUM_ID=1
Assuming that your fourum ids re just numerals.
RewriteEngine On
RewriteCond %{QUERY_STRING} FORUM_ID=(\d+)$ [NC]
RewriteRule ^ http://domain.com/forum/viewforum.php\?f=%1$ [L,R=301]
Upvotes: 1