Forum Moderators: phranque

Message Too Old, No Replies

I need help writing an htaccess rule

         

hussam

2:55 pm on Jun 9, 2010 (gmt 0)

10+ Year Member



I recently deleted a forum section from my forums and any links to it.
But now google is treating the old links (it still has them from it's records) as 404 soft error.
So, I want to return 410 error

links are
/board/extern.php?action=feed&fid=2&type=rss

/board/viewforum.php?id=2


(notice fid, forum id =2)


I have this so far but it won't work

RewriteRule ^/board/viewforum\.php\?id=2$ - [G,L]


What should I put in my .htaccess?

jdMorgan

5:56 pm on Jun 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the .htaccess context, the path to the current .htaccess file's directory is stripped. In this case, this means that the RewriteRule will not 'see' a leading slash on the requested URL-path.

Also, the RewriteRule 'sees' only the requested URL-path, not any query string appended to it. You must use a RewriteCond to test query strings:

RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^board/viewforum\.php$ - [G]

Note that [G] implies [L], so [G,L] is redundant.

See the resources cited in our Apache Forum Charter for details.

Jim

hussam

7:01 pm on Jun 9, 2010 (gmt 0)

10+ Year Member



RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^board/viewforum\.php$ - [G]

Doesn't work :(


EDIT:.
ok, I moved it from /.htaccess
to /board/.htaccess

RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^viewforum\.php$ - [G]

did it. thank you so much :)

g1smd

7:15 pm on Jun 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the requested URL "exactly"
/board/viewforum.php?id=2
here?

If there are any extra parameters the rule will fail as coded.

Personally, I would change ^id=2$ to &?id=2&? to allow for other unwanted additional parameters to be present and the redirect to still work.

It will also fail if it is in the wrong folder.

<edit>OK. I see you fixed it while I was reading and typing.</edit>

hussam

7:31 pm on Jun 9, 2010 (gmt 0)

10+ Year Member



OK. Thanks again. I'm very happy I discovered this forum. :)