Forum Moderators: phranque

Message Too Old, No Replies

.com/~username 301?

Another potential duplicate problem

         

LunaC

3:42 pm on Jun 4, 2008 (gmt 0)

10+ Year Member



Is there any way to 301 or 404 example.com/~username to example.com?

I've tested a few sites and their headers show that .com/~username is 301 redirecting to example.com/~username/ and sending a 200 response while showing the content from /.

example.com/~username/realpage is also landing on a code 200 and showing the content from example.com/realpage.

None of these sites use ~ in the valid URLs so is there a way to redirect with that maybe, or just a match with ~username or even just username? On most of these sites I don't have access to anything beyond .htaccess, so I'm hoping there's some magic that can be done with that.

~randomword sends a 404, so maybe that's a better response for security reasons?

This looks like it could potentially be a very large duplicate problem that I'd like to clear up before it bites me.

(Edited for clarity)

[edited by: LunaC at 4:01 pm (utc) on June 4, 2008]

jdMorgan

3:58 pm on Jun 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The preferred solution would be to set
 UserDir disabled 

in httpd.conf, conf.d, or other server-level config file. See Apache mod_userdir.

If you don't have access to the server config, then yes, these requests can easily be redirected to remove the "~username" -- See Apache mod_alias and/or mod_rewrite.

Jim

LunaC

4:04 pm on Jun 4, 2008 (gmt 0)

10+ Year Member



Oops, you replied as I was editing.

OK, I'll look for that in the one I do have access to the server files, the others I'll try a few more times to get these redirects working.

I don't suppose there's any way to just send a 404 somehow with htaccess for these?

jdMorgan

10:02 pm on Jun 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To respond with a 404, simply rewrite (not redirect) to a non-existent filepath.

Jim