2

Below is example a famous .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

What I know here, the result for URL will be

http://domain.com/about.php will be http://domain.com/about/
http://domain.com/contact.php will be http://domain.com/contact/

Example my URL is http://domain.com/page.php?id=1

How to write a code in PHP which the URL will be http://domain.com/page-name/ according to the .htaccess above.

delicious
  • 37
  • 1
  • 7
  • 2
    It is unclear what you are asking here. The `RewriteRule` you show will not rewrite `domain.com/about/` to `domain.com/about.php` like you seem to be suggesting... what is your question? – Daniel Vandersluis Oct 01 '10 at 15:56

1 Answers1

0
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]*)/$ /page.php?name=$1 [L]

this is what you search for

http://domain.com/testname/ will be translated to http://domain.com/page.php?name=testname

ITroubs
  • 11,094
  • 4
  • 27
  • 25