1

I want to hide the URL of my PHP page; that is, I don't want to write /register.php directly in the href tag, I want to write /register/ and have it open the register.php page directly. I want to do that for all the webpages.

2
  • 1
    You can probably use URL rewriting; what webserver are you using? Commented Jun 9, 2010 at 15:34
  • ok...I am using domain services from justhost. I think they are providing apache webserver. Commented Jun 9, 2010 at 15:57

4 Answers 4

3

In .htaccess try this :

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ $1.php [L,QSA]
Sign up to request clarification or add additional context in comments.

Comments

2

You should take a look at mod_rewrite; it's a Apache module that will help you with it.

Comments

0

umm quick fix is to make a directory called register and save it as the index.php then make sure all your forms have action="/register/" (assuming register is a root folder of domain)

4 Comments

It sounds like he has a number of pages; he just wants /foo/ to redirect to /foo.php for any foo
Hello, I have written code for this... <p class="text13"><a rel="nofollow" href="/register/">Register</a></p> This is not working...saying page not found. I have created a folder called register and inside the folder i have index.php file. Also tell me if I want to open another page inside the same folder how can i do without writting the extension. Thanks, Manoj
Check the website phpclasses.byting.at/browse they are opening a page with the help of the folder name....
if you want to use more than one script your going to want to use the .htaccess method described above
0

Rest easy .. I am new to web development also and I had trouble making this solution work. The detail that is not obvious is that in the php code links, you should remove the extension. For example :

<li><a href="index.php">Home</a></li> should read <li><a href="index">Home</a></li>

Then the extension goes away.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.