Forum Moderators: phranque

Message Too Old, No Replies

how do I rewrite a url to a php script?

rewrite static URL to script

         

Heeren

8:57 am on Dec 29, 2006 (gmt 0)

10+ Year Member



hi
please help me to rewrite url rul in php.
i m trying this one but it is not working pls send me how to configure

Options +FollowSymLinks
RewriteEngine on
RewriteRule condition(.*)\.htm$ /condition-page.php?id=$1

thanks
RELPY ASAP

jdMorgan

5:38 pm on Dec 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How does this code "not work"? Do you get an error? If so, what's in your server error log? Or does it "do nothing"?

Where is this code located -- In the .htaccess file in your "home directory," or somewhere else?

More information, please.

Jim

Heeren

9:31 am on Dec 30, 2006 (gmt 0)

10+ Year Member



hi
there is no error in my website
and this code put in .htaccess file
actually there is no rewriting in the url thats why i ask u
please help me

Heeren

9:32 am on Dec 30, 2006 (gmt 0)

10+ Year Member



and the .htaccess file is in home directory
and the rule is not working
apache module is activate on my server

jdMorgan

4:13 pm on Dec 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Back up and try something simple, like this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^foo\.html$ http://www.example.com/bar.html [R=301,L]

Request the page "www.example.com/foo.html" and you should see "bar.html" appear in the address bar, even if neither page exists.

Jim

Heeren

6:11 am on Jan 2, 2007 (gmt 0)

10+ Year Member



thanks
its working
but for the dynamic page like php with querystring
what should i do

Heeren

6:18 am on Jan 2, 2007 (gmt 0)

10+ Year Member



like this
condition-page.php?id=$1

i want to rewrite
condition/1.html
or
condition-page/1.html
or
conditions/natural.html

give me reply
thanks

jdMorgan

3:15 pm on Jan 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only problem I see is that you say you want to rewrite ".html" files, but the rule specifies ".htm" files.

I would suggest:


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^condition([^.]*)\.ht[b]ml$[/b] /condition-page.php?id=$1 [L]

Jim