Execute .php to .html
Moderator: General Moderators
Execute .php to .html
Hi... I want php file shown in browser as .HTML or like folder. Here I explain:
I have php code in (index.php) as <a href="cat.php?Id=$id"> something like this.Now When user click the link it show in browser as it be,like ...cat.php?Id=3 . But I want here , when user go to(by click) cat.php?id=$id the browser show the URL as ...cat/3.HTML or ...cat/3
Cat = SQL column name
Id= SQL 'cat' fields.
How do I do this...
Thanks in advance...
I have php code in (index.php) as <a href="cat.php?Id=$id"> something like this.Now When user click the link it show in browser as it be,like ...cat.php?Id=3 . But I want here , when user go to(by click) cat.php?id=$id the browser show the URL as ...cat/3.HTML or ...cat/3
Cat = SQL column name
Id= SQL 'cat' fields.
How do I do this...
Thanks in advance...
Re: Execute .php to .html
You can't show the user a different URL than the one they went to.
The subject is called "URL rewriting". You instruct Apache to rewrite "/cat/3.html" (what the user sees) to "cat.php?id=3" (what your PHP code actually needs).
Learn a bit about it before you continue, and then the following won't look so cryptic:
The subject is called "URL rewriting". You instruct Apache to rewrite "/cat/3.html" (what the user sees) to "cat.php?id=3" (what your PHP code actually needs).
Learn a bit about it before you continue, and then the following won't look so cryptic:
Code: Select all
RewriteEngine on
# Turn /cat/#.html to cat.php?id=#
RewriteRule ^/?cat/(\d+)\.html$ cat.php?id=$1 [L,QSA]Re: Execute .php to .html
Hi... Thank you. I am learning this... I can achieve this type now. What should I do if the same think as cat.php?Id=3&pg=2
Re: Execute .php to .html
Link to /cat/3.html?pg=2.
Re: Execute .php to .html
Hi...I just improved ( I think ) ... Here I removed .HTML now it looks as local host/3 for local host/cat.php?Id=2 with htaccess Rewrite rule ^/?(\d+) $ cat.php?Id=$1 [L,QSA] . Now I want to show cat.php?Id=3&pg=5 to local host/3/5
Re: Execute .php to .html
/cat/3/page/5 is a far more meaningful URI than /3/5
That said
You may be interested in this htaccess tester
That said
Code: Select all
^/?(\d+)/(\d+)/? cat.php?id=$1&pg=$2Re: Execute .php to .html
Works fine. But next page URL take the previous no.
Ex. local host/cat/3/page/1 when I click 2 page it show the URL as local host/cat/3/pg/cat/3/pg/2 how can I rectify this
Ex. local host/cat/3/page/1 when I click 2 page it show the URL as local host/cat/3/pg/cat/3/pg/2 how can I rectify this
Re: Execute .php to .html
Sounds like you're using relative instead of absolute links. Try adding a leading slash.
Re: Execute .php to .html
Oh...thanks... Can we use it with relative links ...