...

View Full Version : Hide/remove address bar URLs for PHP application



campionelu
08-01-2011, 10:56 AM
Hello:

I developed an PHP application (WAMPserver) which will run on a company's internal server, and I want to hide/remove the URLs shown in the browser's address bar.

For example, the address bar

instead of:
http://apps.compania.es/application/rap_calendar.php

to show:
http://apps.compania.es/application/


I've read the Apache URL Rewriting Guide (http://httpd.apache.org/docs/2.0/misc/rewriteguide.html), but I couldn't see the solution to my problem.

Could anyone give me a clear example - solution? :)

mlseim
08-01-2011, 02:19 PM
Look at .htaccess rewrite rules ...

http://www.google.com/#sclient=psy&hl=en&safe=off&source=hp&q=.htaccess+rewriterule+examples&pbx=1&oq=.htaccess+rewrite+ru&aq=1s&aqi=g-s5&aql=&gs_sm=c&gs_upl=1652l6310l0l8480l20l17l0l7l7l0l305l2363l0.7.4.1l12l0&bav=on.2,or.r_gc.r_pw.&fp=da8c3ab7508c4c6a&biw=1024&bih=606


.

campionelu
08-01-2011, 05:17 PM
I've tried many of those examples, but I couldn't find the RewriteRule for my situation.

I was hoping someone here could give me a clear solution.

I just want to hide the URL link that appears in the address bar, not to redirect.

mlseim
08-01-2011, 05:21 PM
Change the name of rap_calendar.php to index.php

Or if you already have index.php, 'include' rap_calendar inside of it.

Do everything with "index.php" ...
That way, you can hide all of the necessary URL variables.

EDIT:

Example,
http://apps.compania.es/application/?p=2

That would display the rap_calendar.php script, and you
would use .htaccess to hide the ?p=2 part.
Basically, you're building a template to display all pages using "index.php".

.

campionelu
08-01-2011, 05:37 PM
I think this would require rewriting the application...
I'll consider it for the next one.

For now, maybe there is a simpler solution at server level.

tangoforce
08-01-2011, 05:52 PM
Not really. As mlseim says, using index means that it can be invisble in the address bar as the server will automatically look for an index file itself.

All you need to do is use index.php and then include your normal file - as msleim says above. It's literally like this:



include('usual-file.php');


Thats it. Any $_POST, $_GET, $_SERVER etc will still be available to your included file.

mlseim
08-01-2011, 07:41 PM
And you should be using one script for all pages (index.php) ...
because it would allow you to display any information from
your database without creating a new page for each category (or whatever).

What is your site about? And if it's what you gave in post #1, it looks like
you already have a database, and lots of information.

tangoforce
08-01-2011, 08:20 PM
And you should be using one script for all pages (index.php) ...
because it would allow you to display any information from
your database without creating a new page for each category (or whatever).


This is exactly how I also write code. Everything goes through index.php where the request is then broken down and analyzed before being put through to other code via included files. I never use seperate files for main code as it becomes too confusing to update them all and remember to check/set variables etc.

All you need is a mode value in the url to tell the script which file to include (eg ?mode=login would include login.php). Job done.

oracleguy
08-02-2011, 06:49 AM
Why exactly are you wanting to do this? Generally speaking there are very few reasons to obfuscate the URL the user is at. It can make it hard or impossible to bookmark pages or send people links. And depending on the implementation the browser's back and next buttons won't function properly.

Based on the response in your other thread it sounds like you think it isn't as clean or something to have the actual URL. You can do some rewriting but making the URL constant the entire time is just annoying for users due to the problems I listed above.

Hiding the URL doesn't make your application any more secure or more professional looking.

campionelu
08-02-2011, 09:25 AM
Thank you all for your input.

I see you are an `OracleGuy`, so I give you this example. An Oracle Web-based application (see atachement) has the same address bar display no matter what module / form / report the user is in (http://aplic.compania.es:8889/forms90/f90servlet?...).

I want my PHP Web-based application to run the same way.

I'm sure this can be done, but I don't know how.
I need advice from some of your PHP developers members with application experience.

I posted a similar thread on the Apache configuration section, because I feel this can be done at server level. :)

tangoforce
08-02-2011, 11:10 AM
I'm sure this can be done, but I don't know how.

So you don't know how but you're sure it can be done? - Yet you refuse to listen to those of us with experience?



I need advice from some of your PHP developers members with application experience.

We've given it to you.

The only other thing you can do is switch to using frames in your html but that is a html issue not for php.

campionelu
08-02-2011, 01:02 PM
It's OK. I might be in the wrong forum section.

Oracleguy, could you please move this thread to Apache configuration?

oracleguy
08-02-2011, 11:34 PM
Thank you all for your input.

I see you are an `OracleGuy`, so I give you this example. An Oracle Web-based application

Wrong use of the word, by 'oracle' its meant to be the dictionary definition of the word, not a reference to Oracle products. :)


Oracleguy, could you please move this thread to Apache configuration?

Sure thing.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum