Page 1 of 1
URL Rewrite without using .htaccess
Posted: Fri Mar 16, 2012 6:17 am
by binay00713
Hello everyone,How can i change the url when I am navigating from one page to another.
for example if the existing url is like "
www.example.com/product.php?name=xyz&q=service" ,I want to change it to "
www.example.com/product/name/xyz/q/service"
But I dont want to use .htacces. How can I do it using php functions only?

Re: URL Rewrite without using .htaccess
Posted: Fri Mar 16, 2012 9:13 am
by azycraze
why are you not interested in using htaccess...?????????
Re: URL Rewrite without using .htaccess
Posted: Fri Mar 16, 2012 9:50 am
by twinedev
The only way you are going to do it with php only (ie, no .htaccess or modifying the conf of apache) is to make a file called index.php and place it in a directory /product/name/xzy/q/service and tell it to call /product.php?name=zyx&q=service
And you will have do this for EVERY item you want mapped over.
In short. You can't. PHP scripts can only run when they are called, so you either need an actual php file to call, or you have to do a rewrite rule to tell it to call it for set conditions.
-Greg
Re: URL Rewrite without using .htaccess
Posted: Fri Mar 16, 2012 9:58 am
by Eric!
You could make a PHP file that handles 404 errors. It can then parse the requested /product/name/xyz/q/service rebuild the query string and redirect to /product.php?name=zyx&q=service
However you will have to either go into your cPanel or .htaccess to tell Apache where to find your PHP script for handling 404 errors.