Create Rewrite rule in htaccess for a user profile Create Rewrite rule in htaccess for a user profile apache apache

Create Rewrite rule in htaccess for a user profile


A site i find useful with .htaccess url rewriting is: http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html

The example:

Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz

Have you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.

RewriteEngine OnRewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1

So in your case you could go for:

RewriteRule ^users/([a-zA-Z0-9_-]+)$ user.php?username=$1RewriteRule ^users/([a-zA-Z0-9_-]+)/$ user.php?username=$1


see https://stackoverflow.com/questions/20610980/mod-rewrite-redirect-except-parked-domainAll www.primary.com go to www.primary.com/webtrees

Options -Indexes +SymLinksIfOwnerMatchRewriteEngine onRewriteBase /RewriteCond $1 !^parked.com/RewriteCond $1 !^piwik/RewriteCond $1 !^wordpress/RewriteCond $1 !^marker.htmRewriteCond %{REQUEST_URI} !^/webtrees/RewriteRule ^(.*)$ /webtrees/$1 [L]