Forum Moderators: coopster

Message Too Old, No Replies

Url Creation PHP and HTML

creation html file in index.php

         

Chetanmosaic

5:03 am on Feb 9, 2012 (gmt 0)

10+ Year Member



Hello all,

I didn't get where to put this so i am posting it into php section.

Here is my query today i have found a website example.com/index.php/blue-widget.html

I just want to know how can i do the same?

g1smd

7:09 pm on Feb 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I wouldn't recommend it.

You only need
example.com/blue-widget

penders

11:43 pm on Feb 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As g1smd says. You'd only do it the other way (with index.php) if you are unable to do it the right way... if perhaps you are running on a shared IIS server and don't have .htaccess etc.

rocknbil

5:14 pm on Feb 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Expanding that a little . . . what you would do is rewrite the request at a server level. For linux an example might be:

RewriteRule ^(blue-widget)$ /index.php?param=$1 [L]

... and index.php would take the $_GET parameter "param" and look up a corresponding database record,

select * from table where url='blue-widget'

Or, if it's not a database, rewrite directly to the script

RewriteRule ^blue-widget$ /blue-widget.php [L]

If your server is IIS version 7, rewriting is built in, you need a module prior to that, such as IsapiRewrite.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Static Rewrite Example" stopProcessing="true">
<match url="^(blue-widget)$" />
<action type="Rewrite" url="/index.php?param={R:0}" />
</rule>
/rules>
</rewrite>
</system.webServer>
</configuration>