测试htaccess的code下线 [英] Test htaccess code offline
问题描述
我想我的网站离线测试,但是这是我的问题:
I wanted to test my website offline, but this is my problem:
如何测试
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
离线?
推荐答案
如果我理解正确的问题,所有你需要做的是确保你的网站指向你的本地PC /服务器的名称。以下是如何做到这一点的OSX,有以下假设:
- 你会被指向到本地机器,具有地址 127.0.0.1
- 你的域名是 yourdomain.com
更换上面用适当的值。
If I understood correctly the question, all you have to do is make sure that the name of your website points to your local PC/Server. Here's how to do it in OSX, with the following assumptions:
- You will be pointing to your local machine, with address 127.0.0.1
- Your domain name is yourdomain.com.
Replace the above with appropriate values.
如何编辑主机文件中OSX
- 打开终端
- 键入编辑主机文件
sudo的纳米/私营/ etc / hosts中
- 添加含有一行
127.0.0.1 yourdomain.com
- 添加含有一行
127.0.0.1 www.yourdomain.com
- 保存hosts文件
- 通过运行以下命令清空DNS缓存
dscacheutil -flushcache
- Open the Terminal
- Edit the host file by typing
sudo nano /private/etc/hosts
- Add a line containing
127.0.0.1 yourdomain.com
- Add a line containing
127.0.0.1 www.yourdomain.com
- Save the hosts file
- Empty the DNS cache by running the command
dscacheutil -flushcache
现在,每次你试图打开yourdomain.com的时候,它会尝试连接到本地机器。要撤消上述情况,只需再次打开该文件并注释掉(或删除),您添加的行,然后刷新DNS缓存。
Now, every time you try to open yourdomain.com, it will try to connect to your local machine. To undo the above, simply open the file again and comment out (or delete) the lines you added, then flush the DNS cache.
这篇关于测试htaccess的code下线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!