如何在 WAMP 服务器中使用 .htaccess? [英] How to use .htaccess in WAMP Server?

查看:30
本文介绍了如何在 WAMP 服务器中使用 .htaccess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了 2 天,我尝试在本地 wamp 中使用 htaccess,但我不能!我知道有问题,但我不知道在哪里...

I searched in web for 2 days and I try to use htaccess in my local wamp but I can't! I know there is something wrong but I don't know where...

首先:我在 apache 菜单中激活了rewrite_module",然后我检查了 phpinfo 页面,我看到该模块被添加到它的Loaded Modules" 部分.

First: I activated "rewrite_module" in the apache menu, then I checked the phpinfo page and I saw that module added to its "Loaded Modules" part.

第二:我检查了httpd.conf并做了一些改变,这是结果(只是重要的部分):

Second: I checked the httpd.conf and made some changes, it is the result (just important parts):

ServerRoot "c:/program Files/wamp/bin/apache/apache2.2.11"
Listen 80
ServerName localhost:80
DocumentRoot "c:/program Files/wamp/www/"

<Directory />
Options FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

<Directory "c:/program Files/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

下一步:我为我的工作区创建了一个别名.这是其 .conf 文件的内容:

Next: I made an alias to my workspace. Here is contents of its .conf file:

Alias /basic_test/ "e:/Projects/basic_test/"

<Directory "e:/Projects/basic_test/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>

下一步:我在我的工作区根目录中放置了一个简单的index.php"和test.php",并通过以下地址测试了别名:--> "localhost/basic_test/index.php"--> "localhost/basic_test/test.php"他们完美地工作......

Next: I place a simple "index.php" and "test.php" in my workspace root and tested the alias by this addresses: --> "localhost/basic_test/index.php" --> "localhost/basic_test/test.php" They worked perfectly...

最后,我在工作区的根目录(index.php 旁边)添加了一个.htaccess"文件,并在其中写道:

Finally, I added a ".htaccess" file to the root of my workspace (beside index.php), and I wrote in it:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^index.php$ test.php
</IfModule>

但是当我尝试通过这个地址测试.htaccess"时出现了问题:--> "localhost/basic_test/index.php"

But the problem occurred when I tried to test the ".htaccess" by this address: --> "localhost/basic_test/index.php"

它显示了一个带有此消息的错误页面:

It shows an error page with this message:

糟糕!此链接似乎已损坏.

Oops! This link appears to be broken.

推荐答案

RewriteEngine on
RewriteBase /basic_test/

RewriteRule ^index.php$ test.php

这篇关于如何在 WAMP 服务器中使用 .htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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