Seo friendly links with single get parameter using htaccess and modrewrite
January 15, 2024This ModRewrite will create SEO friendly links while allowing normal GET links as well.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?article/(.*?)/?$ /article.php?id=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /article\.php\?id=([^\&\ ]+)
RewriteRule ^/?article\.php$ /article/%1? [L,R=301]