I would like that my website to be able to use vanity URLs.
There are 3 diffent types:
1) username - http://www.example.com/username --- it works fine
2) ignore php -extensionless url - it always works fine
3) vanity url
3) postal code and username - http://www.example.com/12345/username I find lot of examples for the first and second example, but not for the third example How can I solve this?
Please help. Thanks in advance!
RewriteEngine on
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://www.example.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://www.example.com/users.php?u=$1 [NC]