0

我无法使 URL 重定向工作。我的文件似乎有问题.htaccess。我正在使用WampServer

以下是 .htaccess 中的代码:

重写引擎开启
RewriteRule ^contactus index.php?file=c-contactus
4

6 回答 6

3
RewriteRule ^/?contactus(/)?$ index.php?file=c-contactus
于 2009-08-17T18:43:03.627 回答
2

在 index.php?file=c-contactus 之前放一个 /

所以它变成:

/index.php?file=c-contactus

或者

RewriteRule ^contactus$ index.php?file=c-contactus
于 2009-08-17T17:54:39.450 回答
1

尝试:


RewriteRule ^/contactus(.*) /index.php?file=c-contactus
于 2009-08-17T18:55:48.593 回答
0

您必须在第一步启用 RewriteRule。

看这里

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

将 AllowOverride None 更改为 AllowOverride All

在 /etc/apache2/sites-enabled/000-deafult

于 2015-04-21T20:37:49.190 回答
0

请确保首先在 Apache 服务器配置中启用了 mod_rewrite 模块。最简单的方法之一是运行 phpinfo() 并查看 Loaded Modules 部分,如下所示: 在此处输入图像描述

如果您在那里没有找到 mod_rewrite,请编辑 /wampserver/bin/apache/conf 路径中的 httpd.conf 文件并取消注释以下行: LoadModule rewrite_module modules/mod_rewrite.so

于 2016-06-17T13:29:29.207 回答
0
RewriteEngine on
RewriteBase /your-project-folder/
RewriteRule ^contactus/?$ index.php?file=c-contactus [L,QSA]

如果您使用 localhost,请为 url rewritebase 提供根文件夹名称(您的项目在其中可用)

例如:如果你的 index.php 文件在firstproject文件夹下,那么设置如下

RewriteEngine on
RewriteBase /firstproject/
RewriteRule ^contactus/?$ index.php?file=c-contactus [L,QSA]
于 2016-10-24T04:20:59.243 回答