0

System: Debian 11

Apache version: 2.4

Blogging system used: Typecho 1.2

Site folder directory permissions: 755

The problem: After configuring the address rewrite according to the tutorials searched on the web, all the pages visited are 404 except for the home page and backend.

Related tutorials.

http://forum.typecho.org/viewtopic.php?t=10782

How to enable mod_rewrite for Apache 2.2

I use the following pseudo-static rules:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

The .htaccess file is in the same directory as index.php.

OwO233
  • 1
  • Does removing the leading slash from the `RewriteRule` work? IE: `RewriteRule ^(.*)$ index.php/$1 [L]` – midnight-coding Feb 19 '22 at 15:43
  • Thank you very much for the suggestion, it's a nice try. But when I removed the slash, my blog post screen still remains 404. – OwO233 Feb 19 '22 at 16:07
  • Do you need the `RewriteBase` line? Try removing that line altogether and then trying again. If that does not work then add the forward slash back in on the `RewriteRule`. .htaccess rules are tricky things. Is this .htaccess file located at the root of your public directory? If this does not work then back to basics, is `mod_rewrite` enabled in your Apache config file(s). On Debian try typing `apache2ctl -V` at the command line to find the config file(s) used, then view / search them to ensure `mod_rewrite` has been uncommented. IE: No leading # – midnight-coding Feb 19 '22 at 23:56
  • @midnight-coding I've tried this action but it's not working and I'm ready to switch to using a static blog template. Thank you for all the help you have given me. – OwO233 Feb 20 '22 at 13:11

1 Answers1

0

Do the following, may be it work:

  1. Enable mod_rewrite module in Apache and restart:
sudo a2enmod rewrite
sudo systemctl restart apache2

  1. In Apache config, set AllowOverride All for your site's directory & Restart Apache:
<Directory /var/www/html/your-site-dir>
    AllowOverride All
</Directory>

sudo systemctl restart apache2

  1. Ensure .htaccess is in site's root with correct rewrite rules.
  2. Set directory permissions to 755 and file permissions to 644.
find /path/to/your/site -type d -exec chmod 755 {} \;
find /path/to/your/site -type f -exec chmod 644 {} \;

  1. Check Apache error logs for insights.
tail -f /var/log/apache2/error.log

  1. Enable rewrite rule logging and check log.
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/apache2/rewrite.log"

  1. Clear browser cache or use incognito mode & Ensure Typecho is compatible and up to date or As a last resort, backup and reinstall Typecho.
  2. Remember to restart Apache after configuration changes.
sudo systemctl restart apache2

I hope this will work....Goodluck,

#Apache-Age

saima ali
  • 133
  • 9