mamp pro htaccess rewriteRule无法正常工作

时间:2015-02-18 09:31:59

标签: php apache .htaccess mod-rewrite mamp-pro

我已经搜索了很长时间,但我无法弄清楚为什么Rewrite Rule无效。我想翻译这个网址

  

http://localhost/uniwood/template-allgemein.html?postname=kontakt&pageid=27

  

http://localhost/postname/kontakt.html

这里是htaccess文件中的代码

RewriteEngine On
RewriteRule ^postname/([^/]*)\.html$ /uniwood/template-allgemein.html?postname=$1&pageid=27 [L]

我正在我的机器本地使用mamp pro网络服务器并检查AllowOverride是否已开启"所有"。

我没有犯任何错误!也没有错误日志!

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On

RewriteCond %{THE_REQUEST} /template-allgemein\.html\?postname=([^\s&]+)&pageid=27 [NC]
RewriteRule ^ /postname/%1.html? [R=302,L,NE]

RewriteRule ^postname/[^.]+)\.html$ /template-allgemein.html?postname=$1&pageid=27 [L,NC,QSA]