Back to Home

Human-readable URL for SEO: setup on Apache and Nginx

The article examines the implementation of human-readable URL for improving SEO. Settings in CMS, Apache/Nginx servers, migration automation and error elimination are described. Code examples and CDN integration recommendations are provided.

Human-readable URL: full setup for maximum SEO effect
Advertisement 728x90

SEO-Friendly URL Optimization: Server and CMS Setup Guide

SEO-friendly URLs replace dynamic parameters with readable paths, boosting relevance for search engines. Instead of site.com/products.php?category_id=102&item_id=9452, use site.com/catalog/laptops/iphone-15-pro. This structure conveys site hierarchy and keywords directly in the address, making crawling and analysis easier.

A proper SEO URL uses lowercase letters, hyphens to separate words, and skips UTM parameters. Keep the path to 3-5 words with the exact target keyword. Example: site.com/blog/seo-optimization instead of site.com/p?id=3312&ref=main.

Benefits include higher click-through rates in search results, better keyword relevance, improved crawler navigation, easier sharing, and lower bounce rates.

Google AdInline article slot

Setting Up SEO URLs in Popular CMS Platforms

WordPress: In settings, select %postname% or /%category%/%postname%/, save — .htaccess updates automatically. Verify mod_rewrite is enabled.

Joomla: Enable SEF URLs and Apache Rewrite, rename htaccess.txt to .htaccess.

OpenCart: Turn on SEO URL in server settings, set aliases for categories and products, rename .htaccess.txt.

Google AdInline article slot
# Check mod_rewrite on Apache
apache2ctl -M | grep rewrite

Server Configuration: Apache and Nginx

Apache via .htaccess

Enable mod_rewrite:

sudo a2enmod rewrite
sudo systemctl restart apache2

Basic rules:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]

RewriteRule ^category/([0-9]+)/?$ /index.php?cat=$1 [L]

Flags [L] stop processing, [QSA] preserve query parameters.

Google AdInline article slot

Nginx Configuration

In the virtual host file:

server {
    listen 80;
    server_name site.com www.site.com;
    root /var/www/site;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Test and reload:

sudo nginx -t
sudo systemctl reload nginx

CDN Integration and Automation

For Cloudflare, set up Page Rules with Cache Level: Standard — SEO URLs cache more efficiently than dynamic ones, cutting origin server load by 15-25%.

Migration Automation

Bash script for MySQL (WordPress):

#!/bin/bash
DB_NAME="your_db"
DB_USER="your_user"
DB_PASS="your_password"

mysql -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" <<EOF
UPDATE wp_posts
SET guid = REPLACE(guid, '/?p=', '/post/')
WHERE post_status = 'publish';
EOF

echo "Replacement completed"

Update .htaccess:

sed -i '/RewriteEngine On/a RewriteRule ^\?p=([0-9]+)$ /post/$1 [R=301,L]' /var/www/site/.htaccess

CI/CD with GitHub Actions automates config deployment.

Troubleshooting and Error Fixes

404 Errors on Old URLs

Set up 301 redirects:

RewriteRule ^index\.php\?p=([0-9]+)$ /post/$1 [R=301,L]

Check Coverage report in Google Search Console.

Duplicate Pages

  • Use <link rel="canonical" href="primary-URL">
  • Block dynamic URLs in robots.txt: Disallow: /*?id=

Test redirects:

curl -I -L site.com/?p=123

Key Takeaways

  • SEO URLs boost keyword relevance and click-through rates with zero extra cost.
  • Server setup with try_files or RewriteRule is essential for custom projects.
  • 301 redirects preserve link equity during migration.
  • CDN integration improves performance by 15-25%.
  • Scripts automate the process, minimizing manual work for large sites.

— Editorial Team

Advertisement 728x90

Read Next