$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Permalinks not working Apache + CentOS 7|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Permalinks not working Apache + CentOS 7

matteradmin10PV0评论

I have a running CentOS 7 with Apache 2 mariadb stack with vhosts and Let's Encrypt. I've installed WordPress 4.9.6 on a virtual host using debian style (sites-available -> sites-enabled).

My problem is that I cannot use permalinks. I copy my server configuration below.

getenforce 
Disabled

/etc/httpd/sites-available/example.conf:

<VirtualHost *:80>
    ServerName www.example
    ServerAlias example
    DocumentRoot /var/www/example/public_html
    ErrorLog /var/www/example/error.log
    CustomLog /var/www/example/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example [OR]
RewriteCond %{SERVER_NAME} =www.example
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

/etc/httpd/sites-available/example-le-ssl.conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName www.example
    ServerAlias example
    DocumentRoot /var/www/example/public_html
    ErrorLog /var/www/example/error.log
    CustomLog /var/www/example/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example/chain.pem
</VirtualHost>
</IfModule>

Apache configuration file /etc/httpd/conf/httpd.conf:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    Require all granted 
</Directory>

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

Config. file on the public_html directory /var/www/example/public_html/.htaccess:

# 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

I've enable permalinks settings on WordPress admin:

/%postname%/

Permissions of .htaccess file are:

-rw-r--r-- 1 apache apache 235 Jun 24 13:54 .htaccess

sudo httpd -M shows:

(..)
 rewrite_module (shared)
(..)

I have a running CentOS 7 with Apache 2 mariadb stack with vhosts and Let's Encrypt. I've installed WordPress 4.9.6 on a virtual host using debian style (sites-available -> sites-enabled).

My problem is that I cannot use permalinks. I copy my server configuration below.

getenforce 
Disabled

/etc/httpd/sites-available/example.conf:

<VirtualHost *:80>
    ServerName www.example
    ServerAlias example
    DocumentRoot /var/www/example/public_html
    ErrorLog /var/www/example/error.log
    CustomLog /var/www/example/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example [OR]
RewriteCond %{SERVER_NAME} =www.example
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

/etc/httpd/sites-available/example-le-ssl.conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName www.example
    ServerAlias example
    DocumentRoot /var/www/example/public_html
    ErrorLog /var/www/example/error.log
    CustomLog /var/www/example/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example/chain.pem
</VirtualHost>
</IfModule>

Apache configuration file /etc/httpd/conf/httpd.conf:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    Require all granted 
</Directory>

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

Config. file on the public_html directory /var/www/example/public_html/.htaccess:

# 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

I've enable permalinks settings on WordPress admin:

https://example/%postname%/

Permissions of .htaccess file are:

-rw-r--r-- 1 apache apache 235 Jun 24 13:54 .htaccess

sudo httpd -M shows:

(..)
 rewrite_module (shared)
(..)
Share Improve this question asked Jun 24, 2018 at 18:02 Damon HillDamon Hill 158 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

For the next person, be sure to set AllowOverride All in the correct directory. In Damon's case he set AllowOverride All in the /var/www/html directory, but his site is located in /var/www/example/public_html. I could be wrong, but the AllowOverride setting is specific to the directory. Damon should add the AllowOverride All setting to the /etc/httpd/sites-available/example.conf and /etc/httpd/sites-available/example-le-ssl.conf files. Without this setting the .htaccess file wordpress uses will work.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far