问题描述
||
我的服务器上有一个book.html
我需要像这样访问网址
http://www.domain.com/book
那可能吗?
谢谢
导航
解决方法
我的服务器上有一个book.html,我需要创建一个类似这样的规则
需要访问类似http://www.domain.com/book的网址,它将起作用
那就是简单的mod_rewrite东西。如果您使用启用了mod_rewrite的Apache:
RewriteEngine On
RewriteRule ^book$ /book.html [NC,L]
或者,您可以为此目的使用Apache的Multiviews。
,是的,写在RewriteEngine On
之后,
RewrireRule ^book$ /book.html [NC,L]
如果要对所有.html文件使用此规则。
写这个
RewrireRule ^([a-z0-9]+)$ /$1.html [NC,L]
,特别:
RewriteEngine On
RewriteRule ^book$ book.html [L]
通常:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\\.html$
RewriteRule ^(.*)$ $1.html [L]