tags:

views:

29

answers:

1

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.

A: 
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