我已经在互联网上搜索并按照步骤操作,但我无法使其正常工作。
步骤1:在apache菜单中激活'rewrite_module'。运行phpinfo()后,它显示模块已经加载。
第2步:我对httpd.conf进行了更改:
<Directory "c:/program Files/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
这是我的.htaccess:
RewriteEngine On
RewriteRule ^tempor\.com/([^/]*)\.htm$ /tempor.com/index.php?page=$1 [L]
目标:重写网址 localhost / tempor.com / index.php?page = about to 的本地主机/ tempor.com / about.htm中
测试结果:什么都没发生。网址没有改变。如果我将一些垃圾文本放入.htaccess,我会收到错误,所以我知道.htaccess正在加载。
答案 0 :(得分:1)
将您的DOCUMENT_ROOT/tempor.com/.htaccess
代码更改为:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /tempor.com/
# external redirection from /tempor.com/index.php?page=about to /tempor.com/about.htm
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+tempor\.com/index\.php\?page=([^&\s]+) [NC]
RewriteRule ^ %1.htm? [R=301,L]
# internal forward from /tempor.com/about.htm to /tempor.com/index.php?page=about
RewriteRule ^(.+?)\.html?$ index.php?page=$1 [L,QSA,NC]