Apache Configuration virtual host and open rewrite mode

Source: Internet
Author: User

Apache Configure virtual host

Modify httpd.conf

Enable virtual hosts
#Include conf/extra/ httpd-vhosts.conf (Find this line, remove the front #)

Comment documentroot "D:/program files/apache/apache2.2/htdocs"

Comment

#<directory/>
#    Options followsymlinks
#    allowoverride None
#    order Deny,allow
#    allow from all
#</directory>

Configuration/con f/extra/httpd-vhosts.conf

The
  code is as follows copy code
<virtualhost 192.168.1.2:80>      # First Virtual host
    ServerAdmin xxx@gmail.com    # Admin mailbox
    ServerName xxx.xx.com      # Bound domain name
    documentroot "D:/www/wordpress"        # Site Directory
    Serveralias xxx.xxx.cn                #网站别名, you can not set the
    ErrorLog logs/ Dummy-host.localhost-error.log "      #日志
    customlog" logs/ Dummy-host.localhost-access.log "Common
</virtualhost>




Apache open rewrite mode

Open Apache configuration file: Apache installation directory/conf/httpd.conf.

Search rewrite: "#LoadModule rewrite_module modules/mod_rewrite.so" will be found to remove the "#" in front of it.

Search allowoverride: Change "allowoverride none" to "allowoverride all". Note: This allowoverride is within the <directory "~/htdocs" > tag. The "~" for Apache installation directory

joins the. htaccess file in the entry file directory, (if the. htaccess file is not created, you can write the rewrite rule in the next file on the Web).

The code is as follows Copy Code
<ifmodule mod_rewrite.c>
Rewriteengine on
Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
</IfModule>




The entry file for my PHP project is index.php

Finally reboot the Apache server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.