0

Yes, I've read a lot of pages and discussions, I've tried a lot of options, but NONE have worked so far!

I'm running my own apache2 server, with WordPress, and when changing from /?page_id=xxx to something else (post name), I'm getting 404 on old (and new pages) I'm making.

As I said earlier, I've done a lot of testing, and my last attempt was too disable all plugins and use a totally fresh copy (new default) of .htaccess

then I changed the settings, but no, 404..

if I'm am having a page on https://example.com/?page_id=279 and change to post name permalinks, it will say: https://example.com/test

if I open https://example.com/test it will say 404. if I'm opening https://example.com/?page_id=279, it will redirect to https://example.com/test ..and of course trigger a 404

WordPress can change the .htaccess.

could it be something in MySQL that wrong or even something with apache2?

update: this are my virtual configuration;

SSL configuration:

<IfModule mod_ssl.c>
<VirtualHost mysite.example.com:443>
    ServerName mysite.example.com
    ServerAdmin arga@localhost
    DocumentRoot /var/www/mysite.example.com
    ErrorLog ${APACHE_LOG_DIR}/argagubben.error.log
    CustomLog ${APACHE_LOG_DIR}/argagubben.access.log combined


SSLCertificateFile /etc/letsencrypt/live/mysite.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mysite.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
Header always set Strict-Transport-Security "max-age=31536000"
</VirtualHost>
</IfModule>


http:

<VirtualHost mysite.example.com:80>
ServerName mysite.example.com
ServerAlias mysite.example.com

DocumentRoot /var/www/mysite.example.com
    <Directory /var/www/mysite.example.com>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.html index.php
        Require all granted

    </Directory>
<Directory /var/www/mysite.example.com/wp-content>
        Options FollowSymLinks
        Require all granted

    </Directory>

ErrorLog ${APACHE_LOG_DIR}/argagubben.error.log
CustomLog ${APACHE_LOG_DIR}/argagubben.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =mysite.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

and these are found in apache2.conf:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options  FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>
<FilesMatch "cpf.">
    Require all denied
</FilesMatch>
8
  • @kero Do you mean main apache.conf or the virtual conf for that site? Jan 4, 2022 at 9:44
  • From what you write, the AllowOverride All might miss in apache settings (and so the .htaccess is actually never considered by the webserver).
    – kero
    Jan 4, 2022 at 9:52
  • @kero updated the question with the config file Jan 4, 2022 at 9:54
  • 1
    @kero o hoooly.. that did actually solve the issue! , and those where the default settings (I think) I followed an LAMP instruction to setup my server.. just write this as an answer so I can "reward" you.. (3 days have I been at this) Jan 4, 2022 at 10:13

1 Answer 1

0

From what you write it sounds like Apache isn't reading/following the .htaccess at all. This can be the case if the AllowOverride setting is not active for that directory. (See this thread on StackOverflow for more information.)

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

Setting this (AllowOverride None -> AllowOverride All) and restarting Apache should solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.