문제

I have one problem with the address bar (in the browser). The homepage url of my website looks like this: http://localhost/Website/index.php

If I write .../Website/home.php it loads the the home.php page. I think it is not safe if anyone can go to any of the webpage they want if know its address. I want to block the automatic url redirection in the address bar. Please anyone help me make so that if someone write the .../home.php address it redirects the browser to index.php as the default page.

올바른 솔루션이 없습니다

다른 팁

The entire concept of the world wide web is that each resource (for example each web page) has a unique resource identifier (address). It is an integral part of how the internet works and you ought to conform to it, rather than avoid it.

Make sure you have a nice big link back to your home page and people will use it if they land on a different page and can't find what they want.

I hope this helps.

in short: you cannot do that. As others mentioned, PHP is a server side language that means it cannot control the browser (i.e. preventing someone to change the URL). Read and follow the links in How does PHP work? to get the know the difference between server side and client side languages.

The Wikipeda articles World Wide Web, Uniform Resource Locator (URL) and Web Server could also be interesting for you to get a basic understanding how the WWW works and what it is about the URLs.

But you can control which files can be accessed. There are two ways:

Web server configuration

Most (every?) web server lets you configure rules to control which files should be accessible (aka access control). Her is an example how to do it with the Apache web server.

PHP: Front Controller

You can also do this with PHP directly (and a little web server configuration). The magic keyword her is the Front Controller pattern. This is e.g. a class that acts as a single point of entry to your application. This means that every request e.g. to

 http://localhost/Website/home.php

or

http://localhost/Website/foo/bar.php

is redirected (forwarded, however you want to name it) to and processed by

 http://localhost/Website/index.php

So in the end you can and have to decide which content the user gets to see if he tries to access a certain URL.
This gives you more control over the (look of) URLs but you have to put more effort into it to configure it.

If you are interested in how this works, I suggest to have a look at the Zend Framework which implements this pattern.

Open question...

Although you can do this, the question is whether you have to do it. If you don't want home.php to be accessible, why do you put it on your web server in the first place?

Or maybe you have a wrong picture of the structure of a website in your head. A single website consists of multiple pages (most times), e.g.

index.php   // is the main page
about.php   // is about the site or you
news.php    // contains the latest news you provide
archive.php // older news or articles
...

It is even wanted that a user / visitor can access these pages directly by entering the URL into the address bar or via a bookmark. This is how a website or the WWW works.

PHP cannot do that; it is a server-side technology and so can't modify the browser's behavior. Simply don't put any other files in the directory and the browser will inform the user that no such file exists when they try to navigate to it.

You can get this result even without frames. If you use javascript and ajax to dynamically load your content your url won't change.

While I never recommend this for googles sake this would be the most nice way of doing it and still work fine with PHP

OK 옵션이 관계를 비활성화하는 옵션을 찾았습니다.그것은 "대상"목록의 변형 설정에 있습니다.

I agree with the answers posted recently.

But if you do not need HTML you can go into FLASH or Java Applet, once those are loaded, your URLs no longer changes.

편집 : /Applications/Utilities/Terminal.app를 실행하고자하는 상태를 지정하므로 분명히 Mac OS X를 실행합니다.

Mac OS X .App 프로그램 은 디렉토리입니다.Mac OS 쉘 명령 open로 시작할 수 있습니다.

Fresh Max OS 단말기 세션에서 프로그램 / 경로 / to / 서버를 열려면 다음과 같이하십시오.

import subprocess
termapp=['open','-a','/Applications/Utilities/Terminal.app']
sp=subprocess.Popen(termapp+['/path/to/server'])
.

터미널의 쉘 명령 버전이 있으므로 open -a가 필요하지 않습니다.

import subprocess
termapp=['/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal']
sp=subprocess.Popen(termapp+['/path/to/server'])
.

두 가지 방법은 Windows가 Windows Manager가 그룹화하는 방법에 미묘한 차이가 있습니다.위를 할 때마다 다른 터미널 프로세스와 트레이의 다른 아이콘을 얻을 수 있습니다.with-a와 동일한 터미널 메인 프로그램 내에서 새 창이 열립니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top