0

Possible Duplicate:
Hide extension and variables using .htaccess

I want to change the my URL.

For example,

from: http://domain-name.com/dir/page1.php to: http://domain-name.com/dir/?page1

What would be the .htaccess file code for this?

I am not using any CMS. It's just a simple PHP website.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Chetan Patil
  • 1
  • 1
  • 1

1 Answers1

1

The transformation you want shouldn't be done because ? is a special character in URLs that stands for "here starts the query string".

For page.php to page transformation here's the code:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ $1 [R=301,L]

RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ $1 [R=301,L]

RewriteRule ^([^/.]+)$ $1.php [L]
Shoe
  • 72,892
  • 33
  • 161
  • 264