1

My htacess code is:

Options +FollowSymLinks

RewriteEngine on

RewriteBase /demo/kingstate/

RewriteCond %{THE_REQUEST} /detail\.php\?id=([^\s&]+) [NC]

RewriteRule ^ id/%1? [R=302,L]

RewriteRule ^id/([0-9]+)/?$ detail.php?id=$1 [L,QSA,NC].

my url changing from http://tinmandevserver.com/demo/kingstate/detail.php?id=1 to

http://tinmandevserver.com/demo/kingstate/id/1 by using a htaccess file but i want a url

like http://tinmandevserver.com/demo/kingstate/propperty-house-victoria.

this is first time i worked on htaccess code .

Subodh Ghulaxe
  • 18,333
  • 14
  • 83
  • 102

1 Answers1

0

You cannot easily use mod_rewrite to perform a lookup from http://...?id=1 (or similar) to http://.../some-long-name unless you add one rule (RewriteRule line) for each number-to-name value pair.

Probably what you want to do is use PHP (and maybe SQL) to lookup the name given the number and then do a redirect. For example:

<?php
    $long_names = array('some-long-name','another-long-name');
    if (!empty($_GET['id'])) {
        header("Location: /demo/kingstate/".$long_names[$_GET['id']]);
        exit;
    }
Dwayne Towell
  • 8,154
  • 4
  • 36
  • 49
  • where i have change in htacess code or in my page?? – user3148637 Feb 24 '14 at 10:02
  • Please explain your question again. I'm not sure what you are asking. – Dwayne Towell Feb 24 '14 at 16:11
  • above i write my htacess code which chnge my dynamic url http://tinmandevserver.com/demo/kingstate/detail.php?id=1 to the static url http://tinmandevserver.com/demo/kingstate/id/1 but my site is a property site so for seo purpose and according to the client requiremnt i want the property name and city of the property with id that means..http://tinmandevserver.com/demo/kingstate/property-apartment-victoria-1 but i dont knw how we get the property name and place in htaccess file because my dynamic url does not have the property and place name. – user3148637 Feb 25 '14 at 08:36