WAMP httpd.config重定向 [英] WAMP httpd.config redirect
问题描述
我使用WAMP本地主机上的 C:\\ WAMP \\ WWW \\
C:\\ WAMP \\ WWW \\ MyProj文\\公共
(根)
设下的项目
在 file1.php
(位于根)我有一个链接到一些假网址(/服务/ .....)。
我想该网址为其他文件重定向 service_router.php
(在同一方向file1.php)。
I'm using wamp on localhost at c:\wamp\www\
.
The project located under: c:\wamp\www\MyProj\public
(root).
In file1.php
(located in root) I have a link to some fake url (/services/.....).
I'm trying to redirect that url to other file service_router.php
(in the same direction as file1.php).
我在做什么,在httpd.config:
I'm doing that in httpd.config:
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot c:\wamp\www\
<Directory "c:\wamp\www\">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/MyProj/public/services/*
RewriteRule . /MyProj/public/service_router.php
</VirtualHost>
但我的WAMP拒绝重新启动。
有什么毛病我的配置?
But my WAMP refuses to restart.
What's wrong with my configurations?
推荐答案
我可以提出几点建议。
如果您要使用虚拟主机,我认为这是一个很好的主意。您需要首先确保本地主机仍有效,其次是你移动实际的项目出了 \\ WAMP \\
文件夹结构的一个好主意。
If you want to use Virtual Hosts, and I consider that a very good idea. You need first to make sure that localhost still works and secondly it is a good idea to move you actual projects out of the \wamp\
folder structure.
因此,这将是你的第一个(很多)虚拟主机一个很好的起点。
So this would be a good starting point for your first ( of many ) VHOSTS
一是地方上的任何您的驱动器例如:
First create a new folder structure somewhere on any of your drives for example
C:\websites\project1\www
现在您的项目复制到www文件夹。
Now copy your project to the www folder.
现在设置的虚拟主机
# must be first VHOST so the that localhost and the wamp menu page still work
# Also makes this the default site so any randon hacks on your ip address
# will come here and hopefully be rejected because it only 'Allows' access
# from this machine ( see Allow Deny )
<VirtualHost *:80>
DocumentRoot "D:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/websites/project1/www"
ServerName project1.dev
ServerAlias www.dqsc.old
Options Indexes FollowSymLinks Includes ExecCGI
<Directory "C:/websites/project1/www">
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
除非你真的想使这个网站提供给世界我可以建议你不要使用允许从所有
。
Unless you actually want to make this site available to the World can I suggest that you dont use Allow from all
.
尝试使用,或者如果你想看到你的内部网络上的任何机器您的网站,只需要使用4四分您的IP地址的前3的第二允许线,这将允许从任何IP访问开始与3四分。
Try using or the second Allow line if you want to see your site from any machine on your internal network, just use the first 3 of the 4 quartiles of your ip address and it will allow access from any ip starting with those 3 quartiles.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.0
现在你需要修改你的主机
文件,以便Windows知道你的新域名。
Now you need to amend your HOSTS
file so that windows knows about your new domain name.
修改 C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机
并添加新站点名称 project1.dev
像这样,你将不得不启动你的编辑器,因为该文件被Windows保护以管理员身份运行 -
Edit c:\windows\system32\drivers\etc\hosts
and add the new site name project1.dev
like so, you will have to launch your editor 'Run as Administrator' as this file is protected by windows :-
127.0.0.1 project1.dev
现在重新启动DNS客户端服务,以刷新窗口DNS缓存,因此看到的你的新域名。打开一个命令窗口,再以管理员身份运行。
Now restart the "DNS Client" service to refresh the windows dns cache so it see's your new domain name. Start a command window, again "Run as Administrator".
net stop "DNS Client"
net start "DNS Client"
您现在应该可以在浏览器中输入 http://project1.dev
,它会找到你的新网站。
You should now be able to enter http://project1.dev
in a browser and it will find you new site.
最后,一旦您测试您的网站工作,把URL重写在新项目的根目录的.htaccess
文件编码。
Finally, once you test that your site is working, put the url rewrite coding in a .htaccess
file in the root of your new project.
C:\websites\www\project1\.htaccess
这篇关于WAMP httpd.config重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!