-1

I have a book.html on my server

I need to access url like that http://www.domain.com/book

Is that possible?

Thanks navi

Naveen
  • 125
  • 3
  • 13
  • http://stackoverflow.com/questions/5729225/hide-extension-in-htaccess http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess http://stackoverflow.com/search?q=%2Bhtaccess+%2Bextension – random May 23 '11 at 15:06

3 Answers3

1

I have a book.html on my server I need to create a rule some thing like that I need to access url like that http://www.domain.com/book it will work

That's simple mod_rewrite stuff. If you're using Apache with mod_rewrite enabled:

RewriteEngine On
RewriteRule ^book$ /book.html [NC,L]

Alternatively, you could use Apache's Multiviews for this purpose.

Berry Langerak
  • 18,561
  • 4
  • 45
  • 58
0

yes write this after RewriteEngine On,

RewrireRule ^book$ /book.html [NC,L]

if you want this rule for all .html files. write this

RewrireRule ^([a-z0-9]+)$ /$1.html [NC,L]
0

Specifically:

RewriteEngine On
RewriteRule ^book$ book.html [L]

Generally:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.html$
RewriteRule ^(.*)$ $1.html [L]
Ondřej Mirtes
  • 5,054
  • 25
  • 36