The MoD rewrite and. htaccess are enabled under Mac OS x/windows

Source: Internet
Author: User
Tags manual writing regular expression


The Apache mode rewrite module provides a rewrite engine based on the regular expression parser to rewrite URLs in real time



Windows
Under Windows, we typically use the administrator account, so enabling these two is simple:



In the Apache installation directory]/conf/httpd.conf find #loadmodule rewrite_module modules/mod_rewrite.so, remove the previous annotation symbol #. If this line is not in use, add it. Verify that the mod_rewrite.so file is in the Modules folder under the Apache installation directory. This enables the MoD rewrite feature.
Found in the Apache installation directory]/conf/httpd.conf


The code is as follows
<directory/>
Options FollowSymLinks
AllowOverride None
Order Deny,allow
Deny from all
</Directory>


Change "allowoverride None" to "allowoverride all" so that all folders are supported. htaccess, or enabled for the specified folder. htaccess, can be installed in the Apache directory]/conf/ Join in httpd.conf


The code is as follows
<directory "d:/sites/example/" >
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,deny
Allow from all
</Directory>


This approach is typically configured with a virtual host, so most of the configuration code will be written to the [Apache installation directory]/conf/extra/httpd-vhost.conf, which is much clearer and easier to manage.



After you restart Apache, it's OK.
After completing the appeal procedure, WordPress will use the link settings in the permalink in WordPress, in addition to the default settings, and the htaccess can be generated directly in its installation directory.



Mac OS X
Instead of using the root account in Mac OS X, you get root-related permissions through sudo. In general, we put the Web site files in a personal directory, such as ~/sites, so that the rights of Mac OS management, compared to Windows, a lot more complicated.



Run sudo vi/etc/apache2/httpd.conf at the terminal, find the #loadmodule rewrite_module modules/mod_rewrite.so, and remove the previous annotation symbol #.
Run sudo vi/etc/apache2/extra/httpd-vhost.conf, join


The code is as follows
<directory "/users/[username]/sites" >
Options Indexes followsymlinks MultiViews
AllowOverride All
Order Allow,deny
Allow from all
</Directory>


So the whole ~/sites can support. htaccess.



Run sudo vi/private/etc/apache2/users/[username].conf, change the allowoverride none to allowoverride all. It should be noted that the previous version of Mac OS X, the path might be/private/etc/httpd/users/[username].conf
In the directory you want to create a new. htaccess, and modify its permissions to 777, here is still the use of WordPress fixed link as an example.
CD ~/sites/wordpress
Touch. htaccess
chmod 777. htaccess the permission to create a new file defaults to 644, which can be seen by Ls-l. htaccess, which is not automatically written to. htaccess, which is more secure, but requires manual writing.



Restart Apache:sudo apachectl after exiting restart
Once you have finished this setup, you can use the fixed link feature of WordPress. Note that if. htaccess is copied directly from Windows, there may be an error in the </IfModule> without matching <IfModule> section in the log. The simple solution is to create a new file, copy and paste it again


Related Article

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.