Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies


Having Trouble with Htaccess..



6:14 am on Dec 8, 2007 (gmt 0)

10+ Year Member

Ok, I am trying to redirect a number of old, deleted files to the main page of my site. The problem is that I have the redirection working properly, but the variables are still being passed and I don't want this to happen. Example:

I have this line in .htaccess -

redirect permanent /forummessage.php http://www.example.com/

The problem is that it will redirect to www.example.com, but it will carry the variables over from forummessage.php if they click from Google.

So let's say that a page was forummessage.php?aid=17. Now, when I redirect, it is going to www.example.com?aid=17. I don't want the $aid to show up anymore. Any ideas? Thanks.


[edited by: jdMorgan at 3:08 pm (utc) on Dec. 8, 2007]
[edit reason] example.com [/edit]


7:17 am on Dec 8, 2007 (gmt 0)

WebmasterWorld Senior Member marcia is a WebmasterWorld Top Contributor of All Time 10+ Year Member

>>redirect permanent /forummessage.php http://www.example.com/

Right, it's carrying the part of the URL after .php with them, that's what happens even if redirecting between subdirectories. Are all the URLs you're redirecting consecutive numbers, or are the some with numbers in between that are being left where they are? And about how many are there you're redirecting, just a few?


8:14 am on Dec 8, 2007 (gmt 0)

10+ Year Member

Basically we completely re-did a really old site. There are something like 300 pages which don't exist any more. Any new files are under a completely different naming format. Should I just leave them and leave Google kick them out over time? I am not concerned about any traffic, I just want to do this in the right way so Google doesn't punish our site. Thanks,



9:13 am on Dec 8, 2007 (gmt 0)

WebmasterWorld Senior Member marcia is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Dave, I can't give you the answer you ultimately need but I did ask questions to help clarify so that when someone who knows for sure comes along they might know what exactly to tell you more quickly.

When you're doing a Redirect as you've indicated, it's actually the Redirect Directive in Mod_Alias:


You really aren't permanently moving them (301), you're eliminating them altogether, which techically, if you look at the documentation, would be a 410 permanently removed.

If you really don't care at all about PR or traffic, 410 is fine, but I personally *for sure* wouldn't use the homepage as the target URL of a 404 or a 410 redirect. I'd do a custom 410 error page of some sort, not only for search engine purposes, but so that anyone who tries to reach one of those old URLs in the future will see that they're gone and know where on the site to continue if they wish. A custom 410 page would accomplish that.

Another thing is that 300 URLs is a *whole* lot of URLs to be doing individually in .htaccess; so given that it's all of 300 URLs with the same URL pattern, you'd be better off using an Apache directive that supports regular expressions, which would enable you to specify the entire range of pages you've eliminated using only a couple of lines of code in .htaccess for far more efficiency and far less work.

mod_rewrite is regex based and would work, and it looks like there are some other directives in mod_alias that support regular expressions as well, and there could be other modules suited to this purpose. But this is where someone else will have to step in tell you the best, most efficient way and how to do it.

Here's just the thread you need to read:

mod_rewrite and regular expressions [webmasterworld.com]

There are more in the forum library [webmasterworld.com].


[edited by: Marcia at 9:31 am (utc) on Dec. 8, 2007]


8:12 pm on Dec 8, 2007 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

If I used a redirect for this then I would do it using ModRewrite:

RewriteRule forummessage\.php http://www.example.com/? [R=301]

The question mark is very important.


Featured Threads

Hot Threads This Week

Hot Threads This Month