Search code examples
.htaccessurlhttp-redirecttransfer

How to use AliasMatch with regular expressions


How can I use AliasMatch in httaccess to transfer a url like this : example.com/userName to this url : example.com/user.php?name=userName.


Solution

  • You don't need to use alias. Try this following code :

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)$ /user.php?name=$1 [L]