Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Hide PHP filename in address bar


  • Please log in to reply

#1
Diego8

Diego8

    Member

  • Member
  • PipPipPip
  • 189 posts
In my website i have a php file used to submit e-mail and when the user does not write a valid e-mail address (or does not correctly complete some other fields) the php shows a run-time made html page with the fields that were not completed right.
The problem i'm having is that when this html page is displayed, the complete route and filename of the php file is displayed in the address bar.
Is there a way i can display another address insted of the php one?.

Thnaks in advance
  • 0

Advertisements


#2
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
http://testomoz.org/...r_button/ff.htm
http://testomoz.org/tbutton/ff.php

If you try those links they both lead to the same page, even though though I don't have a folder called /toolbar_button/ or any thing with a .htm file extension. How this works is mod-rewrite, if you have an apache web server you can use this.

First make a file called .htaccess yep that is right it starts with a dot.

In this put

RewriteEngine on

This turns it on.

RewriteRule ^toolbar_button/ff.htm tbutton/ff.php

This would do the above rewrite. If you know regular expressions you can use this too to rewrite lost of urls that are similar.
  • 0

#3
Diego8

Diego8

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 189 posts
I tryed adding that to an .htaccess file but nothing changed.
Where should i put the .htaccess file? at / folder or in the same folder where the php file i want to rewrite is?.

This is my .htaccess file:

RewriteEngine on
RewriteRule ^error.html folder1/folder2/mail_error.php
  • 0

#4
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
In the / folder. The .htaccess only applies to the current folder and all those below it.

It is possible that mod-rewrite is not enabled by your host, in which case this will not work. Try asking them.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP