Permalink in local wordpress

It could happen that wordpress in localhost doesn’t see textual permalink, such as the article name, or the like, and see only ”simple” permalink with a final suffix such as ?p=123.

The problem is an apache problem. To fix it, you have to:

  • modifying the apache config file, with a name such as apache2.conf or another name, depending of your S.O., by adding something like
<Directory /var/www/your-wordpress-path/>
	Options Indexes FollowSymLinks
	AllowOverride all
	Require all granted
</Directory>
  • then you have to do these bash commands  (in a terminal):
sudo a2enmod rewrite
sudo systemctl restart apache2
  • then you have to put in your (root wordpress) folder an .htaccess file with a content like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /your-wordpress-path/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-wordpress-path/index.php [L]
</IfModule>

your-wordpress-path is the path following http://localhost, so don't have to write http://localhost

At this point you should be able to set a textual permalink, after setting it, save it, and try.

WordPress in localhost: permalinks

There could be some problems to fix setting wp in localhost.

One is to get permalink working: there are at least two steps:

  • a working .htaccess (in the root of wp installation) with a code that wp itself will provide,
  • and a corrert apache configuration (in apache configuration file, such as apache2.conf or httpd.conf), that is you should set something like the following:
<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/html/your-path/to-local-wp>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
  • furthermore you should do this command: sudo a2enmod rewrite
  • and then sudo systemctl restart apache2