Mamp Pro htaccess rewriteRule不起作用 [英] mamp pro htaccess rewriteRule not working

查看:70
本文介绍了Mamp Pro htaccess rewriteRule不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了很长时间,我无法弄清为什么重写规则不起作用.我想翻译这个网址

i have already search for a long time and i could not figure our why Rewrite Rule is not working. i want to translate this url

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

http://localhost/postname/kontakt.html

此处是htaccess文件中的代码

here the code in the htaccess file

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

我正在本地机器上使用Mamp Pro Web服务器,并检查AllowOverride是否在所有"上.

I'am using locally on my machine the mamp pro webserver and checked that AllowOverride is on "all".

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

I do not get any mistakes! Also no error logs!

谢谢!

推荐答案

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

You can use this code in your DOCUMENT_ROOT/.htaccess file:

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]

这篇关于Mamp Pro htaccess rewriteRule不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆