473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Name a page as abc.htm while actual page is word.php?w=abc

hsriat
1,654 Expert 1GB
I have seen this many sites including theScripts, that page is actually .php with some get parameter, but the page can be found at an .htm page with no get parameter.

How can that be done?

eg. If you want to see a word say girl, and the PHP page showing this word is word.php?w=girl.
I want to access the same page at girl.htm

Wikipedia does something similar.
Mar 27 '08 #1
12 1374
ronverdonk
4,258 Expert 4TB
The only reason to do this is to make it a lot easier to add new pages. Take the following and call that word.php[php]
<?php
$newpage=$_GET['w'].'htm';
if (file_exists($newpage))
header ("location: $newpage");
else
echo "page for $_GET['w'] does not exist";
?>[/php]and this one and call that girl.htm
Expand|Select|Wrap|Line Numbers
  1. <body>
  2. This a a girl
  3. </body>
Now when I want to add a word e.g. boy, all I have to do is make some html file with the name 'boy.htm' and call it using word.php?w=boy.

The actual code in word.php is a bit more complicated, but this is a very simplified version. I have used this to allow my users to add text pages (.htm) to the site.

Was this the answer you were looking for?

Ronald
Mar 27 '08 #2
hsriat
1,654 Expert 1GB
Thanks, but I want the completely opposite thing.

I mean I have a page word.php which reads the get parameter (w) and searches the database for that unique id (w) in a table, and displays the result.

So to see details of any x word, which is in the database, word.php?w=x would work.

But I want the result to be shown when the user types x.htm, instead of word.php?w=x

This is what is done in Wikipedia, and here in theScripts too. This is actually very useful to get your site in the search engine's search results.

A good familiar example is here...
word.php?w=php
php.htm
Mar 27 '08 #3
Markus
6,050 Expert 4TB
I believe that's a htaccess job, no?
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine On
  2. # start engine
  3. RewriteRule ^([a-zA-Z0-9])\.html$ word.php?w=$1
  4.  
Not sure whether that is syntactically correct, but it's the right logic.
;)

Regards.
Mar 27 '08 #4
hsriat
1,654 Expert 1GB
I believe that's a htaccess job, no?
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine On
  2. # start engine
  3. RewriteRule ^([a-zA-Z0-9])\.html$ word.php?w=$1
  4.  
Not sure whether that is syntactically correct, but it's the right logic.
;)

Regards.
Even I think you are right, but need to try it first.

And dude you still didn't find a solution to that scalability issue!

Regards,
Harpreet
Mar 27 '08 #5
Markus
6,050 Expert 4TB
Even I think you are right, but need to try it first.

And dude you still didn't find a solution to that scalability issue!

Regards,
Harpreet
Ah, that's a shame.. and you call yourself an expert ;)

Regards
Mar 27 '08 #6
hsriat
1,654 Expert 1GB
Ah, that's a shame.. and you call yourself an expert ;)

Regards
I can't be blamed! I'm a JS expert... you the PHP expert B-)

Regards
Harpreet
Mar 28 '08 #7
Markus
6,050 Expert 4TB
I can't be blamed! I'm a JS expert... you the PHP expert B-)

Regards
Harpreet
Have you had any luck with the .htaccess?
I must do something right!!!!!

Regards ;)
Mar 28 '08 #8
hsriat
1,654 Expert 1GB
Have you had any luck with the .htaccess?
I must do something right!!!!!

Regards ;)
I didn't try it yet.
Had many other things to do. :(

Will tell you if it worked.

Regards
Mar 28 '08 #9
aktar
105 100+
If you have access to the Apaches config file then all you need to do is tell Apache (assuming your server is Apache) to parse HTML files as PHP.

This is how its done:

Expand|Select|Wrap|Line Numbers
  1. AddType application/x-httpd-php .html
In fact you can have ANY file extension for eg.

Expand|Select|Wrap|Line Numbers
  1. AddType application/x-httpd-php .made_up_ext

The other way, as was mentioned earlier is .htaccess
However, you should avoid the .htaccess method as its extremely resource hungry. Thats why some shared hosting companies dont allow it to be used.

Hope this helps,

Regards
Mar 29 '08 #10
Markus
6,050 Expert 4TB
If you have access to the Apaches config file then all you need to do is tell Apache (assuming your server is Apache) to parse HTML files as PHP.

This is how its done:

Expand|Select|Wrap|Line Numbers
  1. AddType application/x-httpd-php .html
In fact you can have ANY file extension for eg.

Expand|Select|Wrap|Line Numbers
  1. AddType application/x-httpd-php .made_up_ext

The other way, as was mentioned earlier is .htaccess
However, you should avoid the .htaccess method as its extremely resource hungry. Thats why some shared hosting companies dont allow it to be used.

Hope this helps,

Regards
That isn't answering his question (although it is still interesting).
Hsriat wants the urls to be seen as one thing but be read as another, i.e. url rewriting (also know as: 'pretty urls').

regards :)
Mar 29 '08 #11
aktar
105 100+
Oppsy, I see it now :)


With this rewrite concept, would you have to set a rule for every page you wish to rewrite?
Mar 30 '08 #12
dlite922
1,584 Expert 1GB
Oppsy, I see it now :)


With this rewrite concept, would you have to set a rule for every page you wish to rewrite?
writing it for every page, kind of defeats the whole purpose.

what's wrong with you?

Your dancing around two issues: hiding extensions and pretty URLs.

they acomplish two different things.
Mar 31 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
18
by: Shinin | last post by:
I am trying to set up a mailto: link so that the actual address that the email is being sent to is obscured and replaced by a name. For example, I have <a href="mailto:jschmoe@abc.com">Joe...
6
by: Mason A. Clark | last post by:
LAST WORD(s): 1. MSIE6 and Firefox will go to the top of the page on command <a href="#top">go upsy</a> even if there is NO name="top" or id="top" They know what a "top" is :-) Opera...
8
by: Umut Tezduyar | last post by:
I know that, in asp.net 2.0, the assembly for the web site is splitted into pieces and each time you build it, it generates a random name for assembly. My question is, if i create a custom web...
1
by: ILoveAccess via AccessMonster.com | last post by:
I have the following forms: frmLeads (main form) frmHistory (subform of frmLeads) *************************** I want to merge the record to MS Word and to look similar to below: Mr....
3
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word...
5
by: SQL Learner | last post by:
Hi Alex (Kuznetsov) and All, This is to follow up with my last post, "Link two tables using partial word match". How can I UPDATE table using partial word match? How can I write a SQL statement...
10
by: dave | last post by:
Hello, I made a function that takes a word list (one word per line, text file) and searches for all the words in the list that are 'shifts' of eachother. 'abc' shifted 1 is 'bcd' Please take...
5
by: Peng Yu | last post by:
Hi, The following code snippet is from /usr/bin/rpl. I would like the it to match a word, for example, "abc" in ":abc:". But the current one would not match "abc" in ":abc:". I tried to modify...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.