如何在WAMP服务器中使用.htaccess?

时间:2021-12-10 11:18:27

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...

我在网上搜索了2天,我尝试在我当地的wamp中使用htaccess,但我不能!我知道有什么不对,但我不知道在哪里......

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.

首先:我在apache菜单中激活了“rewrite_module”,然后检查了phpinfo页面,我看到该模块已添加到其“Loaded Modules”部分。

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

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

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

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

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

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>

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”和“test.php”,并通过以下地址测试别名: - >“localhost / basic_test / index.php” - >“localhost / basic_test / test .php“他们工作得很完美......

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

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

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

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

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

It shows an error page with this message:

它显示包含此消息的错误页面:

Oops! This link appears to be broken.

哎呀!此链接似乎已被破坏。

5 个解决方案

#1


22  

RewriteEngine on
RewriteBase /basic_test/

RewriteRule ^index.php$ test.php

#2


46  

Click on Wamp icon and open Apache/httpd.conf and search "#LoadModule rewrite_module modules/mod_rewrite.so". Remove # as below and save it

单击Wamp图标并打开Apache / httpd.conf并搜索“#LoadModule rewrite_module modules / mod_rewrite.so”。删除#如下所示并保存

LoadModule rewrite_module modules/mod_rewrite.so

and restart all service.

并重新启动所有服务。

#3


22  

click: WAMP icon->Apache->Apache modules->chose rewrite_module

单击:WAMP图标 - > Apache-> Apache模块 - >选择rewrite_module

and do restart for all services.

并重新启动所有服务。

#4


4  

Open the httpd.conf file and search for

打开httpd.conf文件并搜索

"rewrite"

“改写”

, then remove

,然后删除

"#"

“#”

at the starting of the line,so the line looks like.

在线的起点,所以线看起来像。

LoadModule rewrite_module modules/mod_rewrite.so

then restart the wamp.

然后重新启动wamp。

#5


1  

if it related to hosting site then ask to your hosting to enable url writing or if you want to enable it in local machine then check this youtube step by step tutorial related to enabling rewrite module in wamp apache https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option it should be checked Note its very important that after enable rewrite module you should require to restart all services of wamp server

如果它与托管网站有关,那么请求你的主机启用url写入或如果你想在本地机器上启用它然后检查这个youtube一步一步的教程相关的启用重写模块在wamp apache https://youtu.be/xIspOX9FuVU ?t = 1m43s Wamp服务器图标 - > Apache - > Apache模块并检查重写模块选项应该检查注意非常重要的是在启用重写模块后你应该要求重启wamp服务器的所有服务

#1


22  

RewriteEngine on
RewriteBase /basic_test/

RewriteRule ^index.php$ test.php

#2


46  

Click on Wamp icon and open Apache/httpd.conf and search "#LoadModule rewrite_module modules/mod_rewrite.so". Remove # as below and save it

单击Wamp图标并打开Apache / httpd.conf并搜索“#LoadModule rewrite_module modules / mod_rewrite.so”。删除#如下所示并保存

LoadModule rewrite_module modules/mod_rewrite.so

and restart all service.

并重新启动所有服务。

#3


22  

click: WAMP icon->Apache->Apache modules->chose rewrite_module

单击:WAMP图标 - > Apache-> Apache模块 - >选择rewrite_module

and do restart for all services.

并重新启动所有服务。

#4


4  

Open the httpd.conf file and search for

打开httpd.conf文件并搜索

"rewrite"

“改写”

, then remove

,然后删除

"#"

“#”

at the starting of the line,so the line looks like.

在线的起点,所以线看起来像。

LoadModule rewrite_module modules/mod_rewrite.so

then restart the wamp.

然后重新启动wamp。

#5


1  

if it related to hosting site then ask to your hosting to enable url writing or if you want to enable it in local machine then check this youtube step by step tutorial related to enabling rewrite module in wamp apache https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option it should be checked Note its very important that after enable rewrite module you should require to restart all services of wamp server

如果它与托管网站有关,那么请求你的主机启用url写入或如果你想在本地机器上启用它然后检查这个youtube一步一步的教程相关的启用重写模块在wamp apache https://youtu.be/xIspOX9FuVU ?t = 1m43s Wamp服务器图标 - > Apache - > Apache模块并检查重写模块选项应该检查注意非常重要的是在启用重写模块后你应该要求重启wamp服务器的所有服务