I got notifications from Google webmaster tool that I have duplicated page titles.
It was properly to browse mysite.com/file.php but I do not know why mysite.com/file.php/ is showing some of content by file.php.
Please advise how to remove/disable content showing when browse mysite.com/file.php/
1st: You might have a filename file.php and directory file.php. Check those out.
2nd: You might have .htaccess rewrite rule, that messes stuff up, if you do check out the syntax on that.
When you hit /file.php, or /file.php/ what changes is pathname that the browser "sees".
In first case, it is /, in second case it's /file.php.
Hence, when you use relative path (to images, stylesheets, etc), in second case the browser will send requests to wrong URIs.
To avoid that, use <base url="http://example.com/path/to/site/root/"> in your HTML
Related
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 :-)
I have a wordpress site with a page named domain.com/dogs. I want to change that exact page to a regular blank white page that I can type text or html in and be able to turn this feature on and off easy enough manually.
What will the name of the file be that I'm replacing it with? domain.com/dogs or domain.com/dogs.php etc? Remember I want it to be EXACTLY the same url.
Thank you so much!
You have to actually find the file that you're talking about on the server or
use GoogleChrome: Right-click(on page)>inspect element > Network (tab).... where you will find the file. The file name and extension will be shown.
Once you know the page extensions you will know what to put:
domain.com/
NOTE: This will work unless there is a masking script that rewrites the url of address bar.
Then you have to go into the server and edit the file itself, and delete all of the contents of the page. Then you can start a new page with the standard HTML headers and include the text you want. NOTE: MAKE SURE THAT YOU SAVE THE FILE WITH THE SAME NAME AND EXTENSION TO THE SAME LOCATION, this will do what I think you're trying to achieve.
I hope it helps.
I have one dynamic website with back end control panel which contains ckEditor for data entry. ckEditor inserts images with path like: /userfiles/image1.jpg and when I call page to display on user interface it shows perfect if I access it from main url but due to some reasons few section we have to move on a sub folder and when I access same page from that subdomain it fails in displaying image.
when I checked url of the image, it shows like:
app1.mysite.com/userFiles/image1.jpg But the actual path is:mysite.com/userFiles/image1.jpg.
Is there any trick or technique to solve this?
I am using PHP.
You can define a <base> in your <head>:
http://www.w3schools.com/tags/tag_base.asp
To do ist with PHP is hard. Changing it beforehand to an absolute URL might be the best way, changing it afterwards means HTML scanning, finding the images, check wether the url is absolute or relative and change it, if needed.
How do I remove path inforation from a url?
For example in this url, http://stackoverflow.com/questions/ask, I want the user to only see http://stackoverflow.com. Is this possible to do?
I do a redirect in PHP from my root directory to path Foo. I don't want Foo to display in the URL.I also do a page reload of sorts using window.location.href = domain_name/foo. Similarly I don't want foo to display in the URL.
Is this possible to implment in Javascript or PHP or do I have to configure Apache to do this?
You cannot manipulate URLs in the browser's address bar using PHP or JavaScript. But you have guessed correctly, this is something that can be configured in Apache. For a primer on URL rewriting, take a look at this article.
I have seen websites that keep the user on the homepage and use AJAX to change the page content.
You should make yourself sober and then consider if you really want to hide anything and if your web site would work at all.
However, I can answer you already - it wouldn't.
We are using path information for the reason. And you'd better see it.
Read up on URL masking:
htaccess mask for my url
http://www.willmaster.com/library/web-development/URL-masking.php
etc... This cannot be handled in JS.
If you REALLY wanted to, you could do this in PHP: you would need to create an index.php page that was set up to handle the loading of other pages, and add a handler at the top of every page that detects the REQUEST_URI that sets any other link to redirect (header()) to the index page with the filepath stored in $_SESSION or another retrievable location. The index page would then render the requested page. However, this is ugly, wastes resources, and you're much better off with an apache level rewrite.
I am testing the security of my website. I am using the following URL to load a PHP page in my website, on localhost:
http://localhost/domain/user/index.php/apple.php
When I do this, the page is not loading normally; Instead the images, icons used in the page simply vanish/disappear from the page. Only text appears. And also on any link I click on this page, it brings me to this same page again without navigating to the required page. So if I have hyperlinks to other pages, such as "SEARCH", which points to search.php, instead of navigating to the search.php page, it refreshes the index.php page and just appends the page name of the destination page to the end of the URL.
For example, say I used the link above. It then loads the index.php page minus the images at it's will. When I click on the "Search" link to navigate to the search page, I see the following in the URL:
http://localhost/domain/user/index.php/search.php
I have a redirection configured to a 404 error page in my .htaccess file, but the page does not redirect to the 404 error page. Notice the search.php towards the end of the URL above. Any other link that I click, reloads the index.php page and just appends the destination page name to the end of the URL like I have shown above.
I was expecting to see a 404 Error but that does not happen. The URL should not even be able to load the page because I do NOT have a "index.php" folder in my website.
What can I do to solve this? All help is appreciated.
Update:
The security concern is that users being able to see a non-existing page (which is quite misleading) like http://localhost/domain/user/index.php/apple.php especially when it does not exists. This makes me feel that this is going to open doors for hackers to exploit the website and compromise its integrity. Can this happen in such a case? I want users to see a 404 error page and any I am willing to any change needed in .htaccess file to accommodate this.
Can you suggest me of some code that I can add to my .htaccess file to accomplish this?
Thank you.
EDIT1:
Here are the contents of my .htaccess files. I have 2 of them. One in domain root and the other in 'user' folder/directory.
/*.htaccess in domain root*/
ErrorDocument 404 /domain/404.php
/*.htaccess in user folder*/
ErrorDocument 404 /domain/user/404.php
EDIT2:
#Pekka Thanks for the link. I added the following code in the .htaccess file (within the user directory)
<Files "mypaths.php">
Options +Includes
SetOutputFilter INCLUDES
AcceptPathInfo Off
</Files>
But still this does not show me the 404 page. Sorry, I am very novice with the .htaccess. Hope you will be able to tell me what I am wrong. Thanks.
The behaviour of why this loads a page:
http://localhost/domain/user/index.php/apple.php
is easily explained. The request is passed to index.php, with apple.php being in the $_SERVER["PATH_INFO"] variable.
So you are in the /user directory as far as the server and the PHP script are concerned.
This is also why no 404 turns up: index.php is always found, no matter which file you specify as the last file.
The browser, however, interprets index.php not as a file, but as the parent directory of apple.php.
Therefore, every relative link you put on the page, say to contact.php is fetched like this:
http://localhost/domain/user/index.php/contact.php
which obviously won't work.
What you may want to do is use absolute paths in images and links, but either way, this is of no concern to security whatsoever.
As a side note, this whole phenomenon is sometimes used to create search engine friendly URLs without having to use mod_rewrite module.
You can turn this behaviour off using the AcceptPathInfo directive.
As for the images, you just have to learn to use absolute paths to your images, which is absolutely necessary
Just instead of images/head.jpg write /images/head.jpg and you will have all your images and styles in place.
As for the /user/index.php/apple.php - why do you want such an odd address?
Why not to use just user/apple.php?
And where is security in your question?