如何在Apache 2.4上启用mod_rewrite? [英] How to enable mod_rewrite on Apache 2.4?

查看:83
本文介绍了如何在Apache 2.4上启用mod_rewrite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Wordpress并希望启用漂亮的urls功能,但是它们不起作用,我认为这是由于mod_rewrite引起的,但是我不知道如何在CentOS 7下的Apache 2.4上启用它. ..

I'm using Wordpress and wanted to enable pretty urls feature, but they don't work, i'm thinking that it's because of mod_rewrite, but i don't know how to enable it on Apache 2.4 under CentOS 7...

我已经尝试过:

grep -i LoadModule /etc/httpd/conf/httpd.conf | grep rewrite

但是什么都没有... 还想知道加载所有Apache模块会带来不好的后果还是不好的做法?

but nothing... Also would like to know it loading all Apache modules has any bad consequence or is it bad practice?

推荐答案

我找到了一种方法来了解模块是否已加载,这是命令列出启用的模块的方法:

I found the way to know if a module is loaded or not, here's to command to list the modules enabled:

apachectl -M | sort

它将按字母顺序列出所有已启用的模块.

It will list all enabled modules alphabetically.

Wordpress具有.htaccess,但默认情况下会启用rewrite_module以供使用:

Wordpress has an .htaccess but default where it enables rewrite_module for its use:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

我唯一要做的就是将其添加到/etc/httpd/conf.d/vhosts.conf

The only thing that i had to do was add this to the vhost.conf file at /etc/httpd/conf.d/vhosts.conf

<Directory /var/www/mysite>
    Options Indexes FollowSymLinks
    Require all granted
    AllowOverride All
</Directory>

那是因为我正在处理该文件中的主机.但这可以在httpd.confhttpd.conf

That's because I'm handling my hosts in that file. But it could be done at httpd.conf, or any other .conf file that is Included to the httpd.conf

谢谢...

这篇关于如何在Apache 2.4上启用mod_rewrite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆