Seo friendly links with single get parameter using htaccess and modrewrite

January 15, 2024

This 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]




Comments

There are no comments.


Comment on this Article

Your email address will never be published. Comments are usually approved within an hour or two. (to prevent spam)