Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule to go to root directory

how to access root directory file in rewriterule

         

rashidfarooq

2:42 pm on Nov 1, 2011 (gmt 0)

10+ Year Member



I have a sub directory "products". there is a file product.php in this directory. I have rewrite the URL. I want to redirect to a file prdct.php which is in root directory.
Actually my URL is as under

http://www.example.com/products/product.php?p_name=product

Now, I want to redirect to

http://www.example.com/prdct.php?p_name=product

I have written the following RewriteRule for this

RewriteRule ^products/([A-Za-z0-9-]+)/?$ prdct.php?p_name=$

But the Problem is prdct.php exists in root directory. What should I do here to redirect it to root directory's prdct.php file.
Note: I don't want to write http://www.example.com/prdct.php to access it, because it creates problem in my URL Rewriting.

lucy24

11:31 pm on Nov 1, 2011 (gmt 0)

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



Before anything else: Go off and do some reading and get a rock-solid grip on the difference between redirect and rewrite. They look very similar on paper, but are completely different behind the scenes.

Once you've done that, you can come back and explain what you mean by "prdct.php?p_name=$". But only after you've got your Redirects and Rewrites sorted out.

g1smd

12:24 am on Nov 2, 2011 (gmt 0)

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



Please read recent threads for several almost identical questions with exactly the same coding errors in the supplied example.