Enable. htaccess in centOS (Remove php suffix access)

Source: Internet
Author: User

Enable. htaccess in centOS (Remove php suffix access)

My requirement is: Change api/x. PHP to api/x for access. I tried to find a lot of information on the Internet and I agree with the following statement.

Prepare the. htaccess file as follows:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ (. *) $ X. php [E = PATH_INFO: $1, QSA, PT, L]
</IfModule>

1. Edit the httpd. conf file

A-in the httpd. conf file in the etc/httpd/conf/directory, find:

LoadModule rewrite_module modules/mod_rewrite.so

If there is # above, cancel it. If not, do not modify it by default. (But I noted it later and it will take effect again)

B-set AllowOverride

Find the following script in httpd. conf.

<Directory/>
Options FollowSymLinks
AllowOverrideNone
</Directory>

Change None to All (I changed AllowOverrideNone in the directory where the project is located)

2. Restart the Apache Environment

Systemctl restart httpd

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.