[php]Want to know how to creat address like example.com/anything

neha.u1179

New Member
Messages
6
Reaction score
0
Points
0
HI,
i Want a php code that creat address like example.com/anyname . i know that this address will lookup in anyname derectory in example.com domain . but even there is no directory(anyname) than how can i assign this address to a perticular page.

{like wordpress parmalinks }
 

lostcommander

Member
Messages
52
Reaction score
0
Points
6
I am sorry if your first language is not English, but I would recommend that you use a word processor (MS-Word, Open Office - Writer, Google Docs) to create any technical posts you want to put on the internet, including help forums. The grammar, spelling, and wording can be tricky with the meaning of the sentence changing quickly with an error, and a word processor can help with the first two (grammar and spelling).

I think that what you are asking is:
How do I place a file on my example.com webserver at www\directory\page.php and access this file on the web using http://www.example.com/page.php ?
If this is not what you are asking, then perhaps someone else on this board can interpret your question differently, or you could try re-writing it.

In answer to the question I think you are asking, there are a few ways to do that PHP and/or Apache's .htaccess files:
1 (PHP) Write an index.php or redirect.php file, send it a $_GET or $_POST variable like "page=filename", and use a switch statement and header("Location...") to redirect the user to the page you want them to be viewing. This does actually change the URL they see in the address bar and presumes you can use a switch statement and the filename to parse out which directory they should be directed to.
2 (database+PHP) Similar to #1, but use a database table to define and track permalink names and their target files.
3 (.htaccess) Write a .htaccess file that instructs the server to use a file from a location other than the one requested by the web browser. This method can be used to leave the user's requested URL unaltered while still giving them different content.
4+ () There are more ways to do this if these 3 are not sufficient. Good luck.

You might find this htaccess generator helpful, or at least a good place to start seeing what is going on. http://www.htaccessredirect.net/index.php

Edit: P.S. Wordpress permalinks simply look up content from the database based on the "post_name" or "post_id" field from the "posts" table, and then generate the page with PHP based on the database information. The URL is crafted using .htaccess to hide the assembly page(s).
 
Last edited:
Top