change php page url using htaccess

I want to change the url from

http://mywebsite/address.php?state=oh&office_id=1425

to

http://mywebsite/office/{variable inside my php page}.php

appreciate if you can help me

-------------Problems Reply------------

This should work:

RewriteEngine On

RewriteRule ^office/([0-9]+).php$ address.php?state=oh&office_id=$1

Which would result in:

http://expample.com/office/1425.php

Or if you'd like the state to be dynamic as well, you could do this:

RewriteEngine On

RewriteRule ^office/([a-zA-Z]+)/([0-9]+).php$ address.php?state=$1&office_id=$2

Which would result in:

http://expample.com/office/oh/1425.php

I would suggest to have a look at mod_rewrite Apache module. You can do various URL manipulations with it.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Beginner's guide:

http://www.workingwith.me.uk/articles/scripting/mod_rewrite

Category:php Views:0 Time:2011-11-15
Tags: php .htaccess

Related post

  • Clean URL using .htaccess in PHP pages 2014-05-17

    Hi i have a site called finittra.com all menu's are dynamically linked with the page. I tried to make the site as like as a CMS. If i click on the about menu the url shows that http://www.finittra.com/?page=about & if i click on the contact page

  • How to remove part of a URL using .htaccess 2009-07-16

    I have a url like this. /domains/details.php (NOTE: domains is dynamic and can be anything) How do I remove the domains part from the URL using .htaccess so the actual lookup is: /details.php OR it'll be cool if I can get domains into the URL. /detai

  • i have one web site which was static and now i have moved it on dynamic and my all pages url have high page rank so what should i do? 2010-01-06

    i have one web site which was static and now i have moved it on dynamic and my all pages url have high page rank so what should i do ? --------------Solutions------------- Use Redirect directives or mod_rewrite to redirect visitors (and the Google cr

  • Getting two variables in the URL with htaccess 2010-04-02

    What way it is to be to get two GET methods in the URL by htaccess? RewriteRule ^adm/(.*)$ adm.php?mode=$1 I've used that for the example URL: http://www.domain.com/adm/thismode Now I want to get two methods like: http://www.domain.com/adm/thismode/o

  • How can I remove ID variable from URL with htaccess? 2010-08-01

    I'm sorry for complex question. I've got a website that reading contents from MySQL database to get video information just like YouTube. I've 7 columns: id, title, desc, url, date, whosadded, views. What I want to do is to Rewrite the url's from /vid

  • Rewrite url in .htaccess 2011-04-20

    Possible Duplicate: .htaccess url rewrite Hello Friends, I just want to know how can i Rewrite URL in .htaccess file from http://example.com/blogs/123/2/blog-title-goes-here to http://example.com/blogs/blog-title-goes-here Any Help will be greatly ap

  • Help me set URL using .htaccess in CodeIgniter 2011-08-14

    I use CodeIgniter and I want to set URL by htaccess. I have tried many ways but have not succeeded yet. My folder structure : --application ----corntrollers -------public ----------home.php ----------log -------------- login.php -------admin ----view

  • URL Rewriting.htaccess 2011-11-25

    I want to rewrite a URL through htaccess, but I am not getting the solution to do the specific rewriting. For e.g., I have a URL: http://www.yourdomain.com/page/about-us.html Now I want to remove page from above URL, so it should look like; http://ww

  • How do I rewrite a POST request from a form to a user-friendly URL with htaccess? 2011-12-20

    As the topic - How do I rewrite a POST request from a form to a user-friendly URL with htaccess? The scenario: I have a webpage that uses a search-form. When I submit that form using method="post" it works flawlessly. BUT I don't get any text in the

  • How to change page url? 2012-02-01

    How to get page url and then rename the url based on query result at a time in the address bar ? sorry for short description.. How can I change page url (working with a exmple.php?id=2 page but the url would be only the name www.something.org/zzz whe

  • change url using .htaccess [domainname/cms.php?iCmsId=1 covert to domainname/about-us.php] 2012-02-20

    I need to change display of webpage url My webpage have a url like cms.php?iCmsId=1, cms.php?iCmsId=2, cms.php?iCmsId=3 etc.. Now i want cms.php?iCmsId=1 then url will be www.test.com/about-us.php or www.test.com/about-us.html --------------Solutions

  • making clean url with htaccess 2012-03-21

    I am trying to make clean url with htaccess I have a profile.php page and I get user domain name to display his page now if the user for example hit www.XXXX.com/domain I will display his main page it is equivalent to www.XXXX.com/profile.php?id=doma

  • How to change specific page slug with .HTACCESS? 2012-03-29

    I got a website script where it's very difficult to change page slugs. So I thought I can do this with .htaccess. I got my page url like - www.mysite.com/submit So can I change this with .htaccess to www.mysite.com/create ??? Thank you! -------------

  • best way to convert aspx dynamic pages urls in user friendly urls using asp.net 2009-01-22

    what is the best way to convert aspx dynamic pages urls in user friendly urls using asp.net 2.0. I want to convert http://www.mydomain.com/product.aspx?Id=4 in to **http://www.mydomain.com/product4.aspx --------------Solutions------------- By using a

  • Finding previous page Url 2009-04-21

    i am trying to find the url of previous page.Such as if a user navigates from Page A to Page B using Server.Redirect("B.aspx"), page B can display the url referring to it. I have tried using Response.Write(Page.PreviousPage.ToString()); Response.Writ

  • Get full page URL with PHP 2009-09-24

    I am trying to get the entire page URL as a string in PHP - so, if the requested URL is ./foo.php?arg1=test&arg2=test2, I get "./foo.php?arg1=test&arg2=test2". I know that I can get the ./foo.php part from $_SERVER and the variables from $_GE

  • How to dynamically retrieve the page URL within Flash using swfobject / JavaScript 2009-10-29

    I have created my own video player using Flash and AS3. Within the flash movie, i have a link which allows the user to copy the object embed code and page url on their own site, similiar to youtube. The player all works fine and retrieves the right f

  • how to get Company contact page url 2009-11-19

    Hi i have csv file which contains company url list like this www.google.com,www.ibm.com..... Here i want to get contactus or aboutus page url (example http://www.google.com/contact) for each url which is present in csv file i have one idea checking t

  • Is ther a way to get a java applet page URL from the server? 2009-12-23

    Does the server know the page URL of the applet without asking the applet? There's Applet.getDocumentBase() to handle that from the applet itself but I was wondering if there was a way on the server without referring to the applet. --------------Solu

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.114 (s). 11 q(s)