Reputation: 1965
What.htaccess code should I write to turn something like
localhost/article.php?id=something&number=something
into just
localhost/article/id
Thoughts guys?
Upvotes: 0
Views: 42
Reputation: 785128
You can use rules like this in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+article\.php\?id=([^\s&]+) [NC]
RewriteRule ^ article/%1? [R=302,L]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^article/([^/]+)/?$ article.php?id=$1 [L,QSA,NC]
Upvotes: 1