Reputation: 11
So I already have a vanity URL on my site for average users profiles...
basecentre.co.uk/user1
this redirects users to
basecentre.co.uk/userprofile.php?username=user1
using the code below...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^thankyou-page=([0-9]*)$
RewriteRule ^(.*)$ affilates_redirect.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /userprofile.php?username=$1
RewriteCond %{HTTP_HOST} ^www.basecentre.co.uk$ [NC]
RewriteRule ^(.*)$ http://basecentre.co.uk/$1 [R=301,L]
</IfModule>
I am trying to create business profiles too, and was looking to do the same sort of thing but using a different page on my site so say...
basecentre.co.uk/businessprofile.php?businessname=mcdonalds
would become
basecentre.co.uk/mcdonalds
And it wouldn't get confussed with the normal user profiles. Would this work or can you only have ONE vanity URL on your site? If that is true, is there any other option I could use?
Also if this is possible, if you have a username with the same business profile name what would happen?
Thanks for the help!
Upvotes: 1
Views: 104
Reputation: 47229
You could do something such as:
RewriteEngine On
RewriteRule ^page/([^/]*)$ /businessprofile.php?businessname=$1 [L]
RewriteRule ^user/([^/]*)$ /userprofile.php?username=$1 [L]
Which would redirect a user profile for example to basecentre.co.uk/user/...
and a business profile to basecentre.co.uk/page/...
Upvotes: 1
Reputation: 19915
I would recommend to use URL schemes like /user/user1 and /business/macdonalds. This will exclude any collisions.
You could also leave the user profile URLs like /user1, and add /business/macdonalds as a new scheme for business profiles.
Finally, it is not impossible to do what you like, but it is more difficult, because there are several constraints :
Upvotes: 3