


Apache second-level domain name related configuration under windows_PHP tutorial
小编今天给大家总结下 windows 下 apache的二级域名的相关配置
下面就利用本地127.0.0.1进行测试
我们这里以 www.jobs.com 为例,以下代码中的 jobs.com 都可以替换成你自己想要的域名 这里只是为了测试。
我们的目标是,不同的子域名可以访问不同目录下的网站:
1、 开启apache的mod_rewrite功能(肯定是要让它支持重写的)在httpd.conf 找到 把前面的#号去了就行,
接着开启apache的虚拟主机 在httpd.conf 找到 把前面的# 号去了。
2、添加几个域名,在 C:\WINDOWS\system32\drivers\etc 目录中找到hosts 这个文件 记事本打开它,添加如下三个域名
127.0.0.1 www.jobs.com
127.0.0.1 jobs.com
127.0.0.1 news.jobs.com
3、在虚拟主机中填写相关代码 让它有权限访问 www目录,找到Apache2\conf\extra 目录下的 文件并打开 代码添加如下
<span <</span><span VirtualHost </span><span *:80</span><span ></span><span DocumentRoot "E:/www" // 这里是项目的目录 ServerName localhost //你的ip 或者你的域名 </span><span <</span><span Directory </span><span "E:/www"</span><span ></span><span // 这里是项目的目录 Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 </span><span </</span><span Directory</span><span ></span> <span </</span><span VirtualHost</span><span ></span>
然后将www.jobs.com 绑定到 相关jobs项目所在目录 代码添加如下
<span <</span><span VirtualHost </span><span *:80</span><span ></span><span DocumentRoot "E:/www/job" // 这里是jobs所在的具体目录 ServerName www.jobs.com // 你的ip 或者 你的域名 ServerAlias *.jobs.com //这里 用 ServerAlias 让多个域名绑定到同一空间 也就是项目目录 </span><span <</span><span Directory </span><span "E:/www/job"</span><span ></span><span // 这里是jobs所在的具体目录 Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from All </span><span </</span><span Directory</span><span ></span> <span </</span><span VirtualHost</span><span ></span>
弄好之后然后重启apache ,如果重启之后遇到apache启动报错 要查看apache的错误日志,根据需求进行修改。
4、在jobs目录下 建立 文件 在里面添加如下代码
<span RewriteEngine on #让www.jobs.com 访问根目录 RewriteCond %{HTTP_HOST} ^www.jobs.com$ RewriteCond %{REQUEST_URI} !^/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /$1 RewriteCond %{HTTP_HOST} ^www.jobs.com$ RewriteRule ^(/)?$ /index.php [L] #让news.jobs.com 访问news目录 RewriteCond %{HTTP_HOST} ^news.jobs.com$ RewriteCond %{REQUEST_URI} !^/news/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /news/$1 RewriteCond %{HTTP_HOST} ^news.jobs.com$ RewriteRule ^(/)?$ news/index.php [L]<br /><br /><span>我要绑定的是把news.jobs.com绑定到new目录中,所以不仅要在根目录放置</span><span class="wp_keywordlink_affiliate">.htaccess</span><span>文件,<br /><br />还要在new目录中放置.htaccess文件,new目录中的.htaccess写法如下:<br /><br /><span>RewriteEngine On</span><br /><span>RewriteBase /</span><br /><span>RewriteCond %{REQUEST_FILENAME} !-f</span><br /><span>RewriteCond %{REQUEST_FILENAME} !-d</span><br /><span>ErrorDocument 403 /404.htm</span><br /><span>ErrorDocument 404 /404.htm</span><br /></span></span>
一切完成之后 你就可以试试 www.jobs.com job.com news.jobs.com 等访问了 就看到你想要的结果了
如果需要其它二级域名访问的话 按照如上的方法要重复 2 、4 步就可以了,不需要在重启apache了
本文所涉及的只为了测试环境所用 并为对安全性进行校验,请在一切设置好之后用于产品中。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The way to update ByBit exchanges varies by platform and device: Mobile: Check for updates and install in the app store. Desktop Client: Check for updates in the Help menu and install automatically. Web page: You need to manually access the official website for updates. Failure to update the exchange can lead to security vulnerabilities, functional limitations, compatibility issues and reduced transaction execution efficiency.

Detailed explanation and installation guide for PiNetwork nodes This article will introduce the PiNetwork ecosystem in detail - Pi nodes, a key role in the PiNetwork ecosystem, and provide complete steps for installation and configuration. After the launch of the PiNetwork blockchain test network, Pi nodes have become an important part of many pioneers actively participating in the testing, preparing for the upcoming main network release. If you don’t know PiNetwork yet, please refer to what is Picoin? What is the price for listing? Pi usage, mining and security analysis. What is PiNetwork? The PiNetwork project started in 2019 and owns its exclusive cryptocurrency Pi Coin. The project aims to create a one that everyone can participate

The official website entrance of the Coinsuper Exchange: https://www.coinsuper.com. The client download channels are: Windows client, macOS client, and mobile (iOS/Android). Registration requires an email, mobile phone number and password, and you need to complete real-name authentication before you can trade. The platform provides a variety of digital asset transactions, including Bitcoin, Ethereum, etc., with the transaction fee rate of 0.1% for both orders and acceptors. Security safeguards include cold wallet storage, dual-factor verification, anti-money laundering and anti-terrorism financing measures, and with security public

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

Need to download the Gate.io app to start your cryptocurrency journey? This guide details the latest version download steps for iOS, Android, and Windows devices. Simply visit the official website, find the download link and select the appropriate option based on your device. For iOS, it will go directly to the App Store, while Android and Windows users will download the APK or installer for manual installation. Once installed, you can launch the app and set up your account to step into the world of cryptocurrency.

Solve the problem of third-party interface returning 403 in Node.js environment. When we use Node.js to call third-party interfaces, we sometimes encounter an error of 403 from the interface returning 403...

Turbo Virtual Currency Exchange is a well-known digital asset trading platform that provides a variety of convenient trading services and a rich cryptocurrency trading pairs. If you want to download the Turbo virtual currency exchange, you can follow the tutorial below to quickly and easily experience the convenience of digital currency trading.
