Apache configuration: randomly adds a sub folder to a path - php

I have a problem.
I ma moving a system from one server to another and I came across a peculiar problem. There are some pages placed in a subfolder like these:
xttp://test.domain.com/admin/oders.php
xttp://test.domain.com/admin/users.php
xttp://test.domain.com/admin/whatever.php
Now, when I move around the pages, via some simple menu with links I get most of the times correct hits. But from time to time I end up on say:
xttp://test.domain.com/admin/admin/oders.php - which obviously causes 404
When I go back to previous page and press the link again it again works all right. Also when I hover over the links they always show proper paths regardless of whether I am going to get 404 or not. All links are dynamically generated by the scripts but they work perfectly on old server and as I say to a naked eye it all looks OK, right until I press the link.
Anyone has an idea where to look for a bug or which tool to use to see what is happening when I press the link? URL mod rewrite? Domain configuration? I am at a loss.

It sounds like the scripts are getting confused between
[xttp://test.domain.com]/admin/file.php
admin/file.php
file.php
Without seeing how the URLs are generated it's impossible to say how this is happening.

Related

Remove index from URL after file extension has been removed using htaccess

With help on my last question about removing file extensions from the address bar if the page name and file extension were keyed in directly even after using htaccess to remove them, HERE I'm now wanting to remove index from the url. Specifically, if I type in my webpage's URL into a browser like so: http://webpage.com that exact address is what I see in the browser when the page is served up. However, if I click the Home link on my page, which contains a href="index" naturally, what shows in the address bar is http://website.com/index Certainly, I could change the link in my code to a href="http://website.com" to omit the index portion from showing up in the address bar, but that seems like a hack.
I found an SO article HERE that shows a method for removing index.php but I'm a bit lost as to how, or even if the code in that answer (I get particularly stuck when seeing Rewrite Base /
) can be blended in with the code that was given to me HERE to just remove index after the file extensions have already been removed.
My apologies in advance if this isn't a clear explanation, I'm in new territory here. Many thanks in advance!
Doing proper rewriting requires you to build the correct links that you want to see being used by the web (i.e. users and search engines). Don't use URLs in your own links that point to URLs that you consider to be wrong.
The link to the home page likely should be <a href="/">, if you don't like index.
Trying to fix the problem by making the client do two requests, one for index, then receiving a redirect to /, is the hack here. Fix your links - they are under your control for a reason.
Certainly, I could change the link in my code to a href="http://website.com" to omit the index portion from showing up in the address bar, but that seems like a hack.
No, that's what I would do :-)

Infinite additional pages being created in a subdirectory

I'm trying to get to the bottom of an issue Moz's crawler got stuck on. The easy problem we need to fix is that we have duplicates of the same page i.e.:
/capabilities/
/capabilities/index.html
That problem is occurring for a handful or directories. But we also have an issue that seems to be making an infinite loop of pages that can be accessed, just for this subdirectory:
/customer_service.html/
/customer_service.html/contact/index.html
/customer_service.html/contact_us/contact_form.php
/customer_service.html/contact/contact/contact/contact/index.html
/customer_service.html/contact/contact/contact_us/contact_form.php
/customer_service.html/contact_us/contact/contact/contact/index.html
/customer_service.html/contact_us/contact/contact/contact_us/contact_form.php
/customer_service.html/contact/contact_us/contact/contact_us/contact_us/contact/index.html
And on and on and on... I think it stopped crawling just because it reached 24,000 pages. All these pages actually work. Really there only need to be two pages: one for customer service FAQs, and one for contacting the company.
I'm a marketer, not a developer, so all I know is that this is an issue. I'm wondering whether we can fix this using htaccess, or if there is another problem. It seems to me like all these other pages need to be eliminated, not just redirected. Thanks.
edit: added more examples for illustrative and comic purposes
There are two things to do.
One is, like you say, not to allow these URLs to redirect to the main page. Show what you have in your .htaccess file, I will look how you could change it.
On the other hand, it is not sufficient to address the symptom. You have to heal the sickness. Here it means that you have some incorrect links on your site. Most probably these are relative URLs that are missing the initial slash ( contact instead of /contact ).

show web page based on url without actual folders on server

I don't even really know how to ask this question or what this would be called or if it's even possible. I've tried searching but I guess I just can't word the question properly.
What I'm trying to do is have a URL, say mydomain.com/blog/2012/12, but without the folder structure on my server public_html/blog/2012/12/index.php
Well, public_html/blog/index.php exists, but for the rest, I would like when visitors go to the page mydomain.com/blog/2012/12, for the web site to load an index.php file from somewhere else on the server, and show blog archives for December 2012 without a 404 page coming up because that folder doesn't actually exist.
ie, I don't want to have to create folders for every year/month.
Is this possible? I'm sure it's possible, I just can't figure out how to search for this particular topic.

odd url, and difficulty in following the php page flow

I'm trying to understand code that I bought so I can modify it.
In the index.php there are picture links:
<a href="test10,10"><img title="" border=1
src="makethumb.php?pic=product_images/test101.jpg&w=121&sq=N" / ></a>
I don't understand the href since it is not pointing to a page. test10 is an id of a picture. I assumed it was going back to the index.php and the code would extract the test10,10 from the url, but it's not. I know that because I put in trace code as the first line.
The question is, where is the link going to?
I know it that it somewhere in the process it executes a page called profile.php, but nowhere in the source code (doing a global search) is there an explicit call to profile.php.
As a related question, is there a way to profile the code to see what pages it's calling without using xdebug, which for the life of me I can't get working after many hours of trying every suggestion I found here and else where. (I'm using xampp)
The flow is: you enter the site www.site.com/final/index.php. which displays pictures with the link as above. When you click on the picture with an id of test10 it takes you to www.site.com/final/test10,1
thanks
The question is, where is the link going to?
Under normal circumstances, a request to
www.yourdomain.com/current_directory/test10,10
is made.
Usually, Apache will try to find a file of that name, and fail.
If the behaviour you get is different, then there is probably a mod_rewrite rule set up somewhere. Look for .htaccess files (note, files in parent directories affect all children) and check the httpd.conf, httpd-vhosts.conf and other log files for any RewriteRule settings.

CPanel PHP Website - cleanup hijack scenario

Someone had changed my .htaccess, and I have removed that.
But I still have phantom pages like this:
http://www.biztalk-training.com/?puqr=usoe
I don't have any 404.php, 404.shtml, or 404.html pages.
I checked CPanel for redirects on 404, and it looked empty (but would have created a 404.shtml if I filled it in).
If I type in something like this in the browser, I get a 404;
http://biztalk-training.com/anything.html
I'm looking for what to kill, remove or fix to get red of the phantom page. I'm a developer (other platforms) with moderate familiarity with PHP and CPanel sites. I'm used to seeing domainname.com/progname.php?parm=test and I know how that works. But I don't know how the ?puqr=usoe is producing content on my site. They have other pages similar discovered by doing a site: search on google.
Thanks,
Neal Walters
Have you checked your index page? Under normal circumstances, http://www.example.com/?foo=bar will pass the query string (?foo=bar) to the index of example.com and will not produce a 404.
If these malcontents got write access to your server - and it sounds like they did - they could have easily modified your index page.

Categories