Welcome to WebmasterWorld Guest from 54.162.184.214

Forum Moderators: Ocean10000 & incrediBILL & phranque

Redirect a url containing /./

Help needed. Strange behavior after moving to a different hosting

     
11:17 am on May 11, 2018 (gmt 0)

New User

10+ Year Member

joined:May 24, 2003
posts: 34
votes: 0


I have some legitimate links pointing to my site that contains a similar error:

www.mysite.com/example1/.../example3/page.htm

where "/.../" should be "/example2/". This is probably due to a copy-paste of a reduced version of the URL.

To do the redirect, a simply created a directory called "/.../" and put a .htaccess in it with proper redirects. This used to work until yesterday, when I moved to a different host provider. In the dedicated server I have now, the directory called "/.../" can not be accessed, an it returns a 500 Server Internal Error when I try to access to it, even after uploading "/.../page.htm" and requesting directly "/.../page.htm". Also, when I look at /.../ directory with a FTP client, the FTP client marks the directory as a "Disc".

I would apprecciate a lot any suggestion.
5:53 pm on May 11, 2018 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14718
votes: 614


You don't need to create a directory in order to redirect from it. (This is a universal truth. The whole point of a server-side redirect is that you intercept the request before it reaches the requested content--which may or may not physically exist.) You definitely don't want to mess about with anything with a leading . (literal dot).

Why can't you simply redirect as-is? Put the rule in the root along with all other redirects.

RewriteRule ^example1/\.\.\./example3/page.htm https://example.com/example1/example2/example3/page.htm


You weren't trying to do this in mod_alias (Redirect by that name), were you?
7:30 am on May 12, 2018 (gmt 0)

New User

10+ Year Member

joined:May 24, 2003
posts: 34
votes: 0


Hello, Lucy24. Thanks a lot for you answer.

After seeing old method (creating a "/.../" and redirecting with a .htaccess in in) did not work, I tried to do exactly what you say:

>>> RewriteRule ^example1/\.\.\./example3/page.htm https://example.com/example1/example2/example3/page.htm

But it doesn't work (again, 500 Internal Server Error). I think the reason could be that, when server receives the request "https://example.com/example1/.../example3/page.htm", Apache looks for a .htaccess first at "https://example.com/example1/.../example3/", and second at "https://example.com/example1/.../" (even if directory "/.../" does not exist), and maybe the error is caused by Apache trying to access to a directory with a no good name like "/.../"
7:53 am on May 12, 2018 (gmt 0)

New User

10+ Year Member

joined:May 24, 2003
posts: 34
votes: 0


I've tried to access to inexistent urls in my site like

www.mysite.com/.../nonexistingdirectory/nonexistingpage.htm
www.mysite.com/nonexistingdirectory/.../nonexistingpage.htm

And I always get a 500 error, never a simple 404 error.

Definitively that should be something related to "/.../" being a bad name for a directory. It's strange because it didn't happen in my previous host provider. I have no idea about how this behavior can be changed.
9:04 am on May 12, 2018 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:11293
votes: 135


500 Internal Server Error

check your server error log file for clues.

Apache looks for a .htaccess first at "https://example.com/example1/.../example3/",

no.
apache looks first for .htaccess in the document root directory and then in each subsequent subdirectory of the path if appropriate.
4:35 pm on May 12, 2018 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14718
votes: 614


Oh, whoops, I hope you weren't cutting-and-pasting from my post. I left off the [R=301,L] flag because those are used with all mod_rewrite redirects and I was just typing off the top of my head. I also assumed that your htaccess already contains RewriteRules. You didn’t say, one way or the other.

Once a request has met a redirect (with [L] flag in the case of mod_rewrite), it's all over. The server does not say “Hey, let’s go for ### and giggles and see what would have happened if there had not been a redirect”. And, as phranque points out, it goes from top to bottom--or from outside to inside, if that's easier for you to visualize.
10:00 am on May 13, 2018 (gmt 0)

New User

10+ Year Member

joined:May 24, 2003
posts: 34
votes: 0


Don't worry, lucy24 :-) I tried your method (RewriteRule ^example1/\.\.\./) and saw that it din't work before my first post, so I did not use your example code.

>>>> it goes from top to bottom--or from outside to inside

In such a case, I really can not understand why RewriteRule ^example1/\.\.\./ does not work.

Don't you feel it's curious www.mysite.com/nonexistingdirectory/.../nonexistingpage.htm returns a 500 error? If it goes from top to bottom, I would expect a 404 error.

Thanks anyway for your suggestions, I aprecciate a lot.
6:13 pm on May 13, 2018 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14718
votes: 614


saw that it didn't work before my first post, so I did not use
...
I really can not understand why RewriteRule ^example1/\.\.\./ does not work.

Now I'm confused. How do you know it doesn't work, if you decided it didn't work before even trying it?

With flags:
RewriteRule ^example1/\.\.\./example3/page.htm https://example.com/example1/example2/example3/page.htm [R=301,L]
The anchor and path mean that the rule must be placed in the site's root htaccess.

It is possible the server has a rule blocking all access to material beginning in . (dot), although the Apache default is to only block material beginning in .ht (i.e. htaccess and htpasswd). But if so, requests would get a 403 response--and, of course, this would only apply to requests that were not redirected.

What happens when you yourself request this incorrect URL with /.../ in the middle? Do you end up seeing the 403 or 404 screen, or do you get some other message? I'm now talking about what you, as a human visitor, see in your browser, not what you, as the site administrator, see in logs.

The one advantage of a 500-class error over a 403/404 is that error logs should be able to give detailed information. See what they say.

I did some experimenting on my test site to verify that nothing unusual happens if a request involves a directory with name consisting entirely of dots. At least not on a vanilla, shared-hosting Apache 2.2 setup.
4:29 pm on May 14, 2018 (gmt 0)

New User

10+ Year Member

joined:May 24, 2003
posts: 34
votes: 0


I meant I tried the redirect RewriteRule ^example1/\.\.\. and I saw it did not work before my first post. Anyway I've tried again, without result.

When requesting mysite.com/nonexistingdirectory/.../nonexistingpage.htm in browser I get this:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

But when requesting via websniffer to see the headers, I get a HTTP/1.1 400 Bad Request

And when requesting mysite.com/nonexistingdirectory/nonexistingpage.htm, I get a 404 both in browser and in websniffer.

And If I put the redirect RewriteRule ^example1/\.\.\., I get a 500 error both in browser and in websniffer.

I'm so confused :-( I will talk to my host provider.
6:32 pm on May 14, 2018 (gmt 0)

New User

10+ Year Member

joined:May 24, 2003
posts: 34
votes: 0


It's solved :-) Host provider has told me a rule in Modsecurity was blocking the URL.

Thank everybody for your suggestions.
9:18 pm on May 14, 2018 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14718
votes: 614


Host provider has told me a rule in Modsecurity was blocking the URL.
What a shame they won't let you see your own error logs, or you'd have spotted this right away. :( mod_security gives really good, informative error-log entries. (At least on my host. I don't know if it is built into the mod or if server administrators have to make it up on their own.)
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members