简体   繁体   English

RerwiteRule在本地主机上不起作用

[英]RerwiteRule doesn't work on localhost

RewriteEngine on
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]

Why it doesn't work when I request http://localhost/webme/test 为什么当我请求http://localhost/webme/test时它不起作用

I work on localhost Physical root folder is c:\\AppServ\\www\\WebME The script is saved in .htaccess in the root folder 我在本地主机上工作物理根文件夹为c:\\ AppServ \\ www \\ WebME脚本保存在根文件夹的.htaccess中

It should be redirect to http://localhost/webme/index.php?page=test 它应该重定向到http://localhost/webme/index.php?page = test

Your rewrite is changing /webme/test to /index.php?page=test . 您的重写将/webme/test更改为/index.php?page=test The question is if your .htaccess file is in "/webme/" or in the document root ("/"). 问题是您的.htaccess文件是在“ / webme /”还是在文档根目录(“ /”)中。

If your document root is in c:\\AppServ\\www\\ and your .htaccess file is in the webme directory, you need to include "webme" in the target: 如果您的文档根目录位于c:\\AppServ\\www\\而.htaccess文件位于webme目录中,则需要在目标中包括“ webme”:

RewriteRule ^([^./]{3}[^.]*)$ /webme/index.php?page=$1 [QSA,L]

OR by removing the leading slash in your target 或者通过消除目标中的前导斜线

RewriteRule ^([^./]{3}[^.]*)$ index.php?page=$1 [QSA,L]

Otherwise, if your .htaccess is in the document root ("/") then you need to match against it: 否则,如果您的.htaccess位于文档根目录(“ /”)中,则需要对其进行匹配:

RewriteRule ^webme/([^./]{3}[^.]*)$ /webme/index.php?page=$1 [QSA,L,NC]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM