【发布时间】:2017-06-16 05:55:34
【问题描述】:
我有一个主要由数据库驱动的网站,其中有几个页面是硬编码的 html 文件(联系人和地图)。所有其他页面都存储在数据库中。
如何设置我的 htaccess 以允许用户执行此操作,同时根本不更改 url?
www.website.com/contact (-实际上加载了contact.html页面)
www.website.com/about (-实际加载 about.html 页面)
www.website.com/anything (-实际加载 page.php?title=anything)
编辑:我更新的代码
RewriteEngine on
# RewriteBase /mcw/
# i've tried with and without rewritebase
RewriteRule ^(contact|about|index)$ /$1.html
RewriteCond %{REQUEST_URI} !^/(?:contact|about|index)\.html$
RewriteCond %{REQUEST_URI} !^/(?:admins|css|fonts|img|inc|js)/
RewriteRule ^(.*)$ /page.php?name=$1
【问题讨论】:
-
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule ^([^\.]+)$ $1. html [NC,L]
-
你在用路由器吗?
标签: php .htaccess mod-rewrite