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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.