Jump to content

how to rewrite url in php


beboo002

Recommended Posts

Apache I think.

Go into your .htaccess and add:

 

RewriteEngine on
RewriteBase /

 

Then for every page add:

 

ReWriteRule ^animationautomation/$ home1.php?sub_cat_id=1
ReWriteRule ^animationautomation$ home1.php?sub_cat_id=1

 

In case you might want to send variables over the URL you might want to look at this code as well, it's pretty self explanatory: By the way, the below code is only for sending integer variables. This is useful for pages which you want to limit the variable.

 

ReWriteRule ^mypage/([0-9]+)/$ index.php?p=mypage&id=$1
ReWriteRule ^mypage/([0-9]+)$ index.php?p=mypage&id=$1

 

So if you want to send two variables for example you can try:

 

ReWriteRule ^mypage/([0-9]+)/([0-9]+)/$ index.php?p=mypage&id=$1&foo=$2
ReWriteRule ^mypage/([0-9]+)/([0-9]+)$ index.php?p=mypage&id=$1&foo=$2

 

And so 3 variables, go to $3, and so forth.

 

For others you might want to use "(.*)" (without quotes).

 

Sorry if I made a mistake (to those professionals) feel free to correct me. I hope I didn't misunderstand your question.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.